home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 676-700 / 681 / term / source.lha / termRexx.c < prev    next >
C/C++ Source or Header  |  1992-05-09  |  59KB  |  3,647 lines

  1. /*
  2. **    $Id: termRexx.c,v 1.6 92/05/01 12:51:29 olsen Sta Locker: olsen $
  3. **    $Revision: 1.6 $
  4. **    $Date: 92/05/01 12:51:29 $
  5. **
  6. **    ARexx interface support routines
  7. **
  8. **    Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
  9. **        All Rights Reserved
  10. */
  11.  
  12. #include "termGlobal.h"
  13.  
  14.     /* The rexx server commands are contained in lists in which
  15.      * each command name and the approriate routine is
  16.      * stored. The following three structure definitions
  17.      * are required to set up the list properly.
  18.      */
  19.  
  20. struct QueryStruct
  21. {
  22.     UBYTE    *String;
  23.     UBYTE *    (*Routine)(VOID);
  24. };
  25.  
  26. struct ASyncCommandStruct
  27. {
  28.     UBYTE    *String;
  29.     VOID    (*Routine)(VOID);
  30. };
  31.  
  32. struct CommandStruct
  33. {
  34.     UBYTE    *String;
  35.     UBYTE *    (*Routine)(UBYTE *,UBYTE *);
  36. };
  37.  
  38.     /* Global rexx output buffer. */
  39.  
  40. STATIC UBYTE RexxTextBuffer[256];
  41.  
  42.     /* This structure defines a relation between a time unit
  43.      * (microseconds, seconds, minutes) and a string key.
  44.      */
  45.  
  46. struct TimeRel
  47. {
  48.     UBYTE    *Key;
  49.     LONG     Multi;
  50. };
  51.  
  52.     /* Relations between qualifying keywords and time multipliers. */
  53.  
  54. #define NUMTIMEREL 9
  55.  
  56. STATIC struct TimeRel TimeRelations[NUMTIMEREL] =
  57. {
  58.     "MIC",        1,
  59.     "SEC",        MILLION,
  60.     "MIN",        MILLION * 60,
  61.  
  62.     "MICROSECONDS",    1,
  63.     "SECONDS",    MILLION,
  64.     "MINUTES",    MILLION * 60,
  65.  
  66.     "MICROS",    1,
  67.     "SECS",        MILLION,
  68.     "MINS",        MILLION * 60
  69. };
  70.  
  71.     /* Asynchronous commands which can be executed by the
  72.      * rexx server process itself and do not require the
  73.      * term main process to take any action.
  74.      */
  75.  
  76. #define NUMASYNCS 9
  77.  
  78. STATIC struct ASyncCommandStruct ASyncCommands[NUMASYNCS] =
  79. {
  80.     "TERM2FRONT",        (APTR)Term2Front,
  81.     "DEFAULT2FRONT",    (APTR)BumpDefault,
  82.     "WB2FRONT",        (APTR)WBenchToFront,
  83.     "REXX2FRONT",        (APTR)Rexx2Front,
  84.     "DISPLAY2FRONT",    (APTR)Display2Front,
  85.     "CLOSEDISPLAY",        (APTR)CloseDisplay,
  86.     "CLEARDISPLAY",        (APTR)ClearBuffer,
  87.     "CLEARDOWNLOADLIST",    (APTR)ClearDownloadObjects,
  88.     "QUIETEXIT",        (APTR)QuietExit
  89. };
  90.  
  91.     /* Query commands which return miscellaneous system
  92.      * information (these routines are handled asynchronously
  93.      * as well).
  94.      */
  95.  
  96. #define NUMQUERIES 81
  97.  
  98. STATIC struct QueryStruct QueryCommands[NUMQUERIES] =
  99. {
  100.     "BAUDRATE",        (APTR)QueryBaud,
  101.     "BITSPERCHAR",        (APTR)QueryDataBits,
  102.     "PARITY",        (APTR)QueryParity,
  103.     "STOPBITS",        (APTR)QueryStopBits,
  104.     "HANDSHAKING",        (APTR)QueryHandshaking,
  105.     "DUPLEX",        (APTR)QueryDuplex,
  106.     "HIGHSPEED",        (APTR)QueryHighspeed,
  107.     "BREAKLENGTH",        (APTR)QueryBreakLength,
  108.     "SERIALDEVICE",        (APTR)QuerySerialDevice,
  109.     "UNITNUMBER",        (APTR)QueryUnitNumber,
  110.     "MODEMINIT",        (APTR)QueryModemInit,
  111.     "MODEMEXIT",        (APTR)QueryModemExit,
  112.     "DIALPREFIX",        (APTR)QueryDialPrefix,
  113.     "REDIALDELAY",        (APTR)QueryRedialDelay,
  114.     "DIALRETRIES",        (APTR)QueryDialRetries,
  115.     "DIALTIMEOUT",        (APTR)QueryDialTimeout,
  116.     "CONNECTAUTOBAUD",    (APTR)QueryConnectAutoBaud,
  117.     "NOCARRIER",        (APTR)QueryNoCarrier,
  118.     "CONNECT",        (APTR)QueryConnect,
  119.     "VOICE",        (APTR)QueryVoice,
  120.     "RING",            (APTR)QueryRing,
  121.     "BUSY",            (APTR)QueryBusy,
  122.     "PROTOCOL",        (APTR)QueryProtocol,
  123.     "PROTOCOLOPTIONS",    (APTR)QueryProtocolOptions,
  124.     "MACROFILE",        (APTR)QueryMacroFile,
  125.     "DISPLAYMODE",        (APTR)QueryDisplay,
  126.     "PUBLICSCREEN",        (APTR)QueryPublicScreen,
  127.     "SHANGHAI",        (APTR)QueryShanghai,
  128.     "CAPTUREFILTER",    (APTR)QueryCaptureFilter,
  129.     "DSBACKSPACE",        (APTR)QueryDSBackSpace,
  130.     "AUDBELL",        (APTR)QueryAudBell,
  131.     "VISBELL",        (APTR)QueryVisBell,
  132.     "EIGHTYCOLUMNS",    (APTR)QueryEightyColumns,
  133.     "SENDCR",        (APTR)QuerySendCR,
  134.     "SENDLF",        (APTR)QuerySendLF,
  135.     "COLOURMODE",        (APTR)QueryColourMode,
  136.     "COLORMODE",        (APTR)QueryColourMode,
  137.     "EMULATION",        (APTR)QueryEmulation,
  138.     "FONT",            (APTR)QueryFont,
  139.     "STATUS",        (APTR)QueryStatus,
  140.     "SERIAL",        (APTR)QuerySerial,
  141.     "STARTUP",        (APTR)QueryStartup,
  142.     "REQUESTERS",        (APTR)QueryRequesters,
  143.     "TIMEOUT",        (APTR)QueryTimeout,
  144.     "LINE",            (APTR)QueryLine,
  145.     "COLUMNS",        (APTR)QueryColumns,
  146.     "LINES",        (APTR)QueryLines,
  147.     "CURSOR",        (APTR)QueryCursor,
  148.  
  149.     /* Added in revision 1.6 */
  150.  
  151.     "MODEMHANGUP",        (APTR)QueryModemHangup,
  152.     "AUTOCAPTURE",        (APTR)QueryAutoCapture,
  153.     "LOGACTIONS",        (APTR)QueryLogActions,
  154.     "BLINKING",        (APTR)QueryBlinking,
  155.     "CURSORMODE",        (APTR)QueryCursorMode,
  156.     "FONTSCALE",        (APTR)QueryFontScale,
  157.     "SMOOTHSCROLL",        (APTR)QueryJumpScroll,
  158.     "CHARACTERWRAP",    (APTR)QueryCharacterWrap,
  159.     "CURSORWRAP",        (APTR)QueryCursorWrap,
  160.     "NEWLINEMODE",        (APTR)QueryNewLine,
  161.     "INSERTMODE",        (APTR)QueryInsert,
  162.     "NUMERICMODE",        (APTR)QueryNumeric,
  163.     "DEFAULTSTORE",        (APTR)QueryDefaultStore,
  164.     "TUPLOADPATH",        (APTR)QueryTUploadPath,
  165.     "TDOWNLOADPATH",    (APTR)QueryTDownloadPath,
  166.     "AUPLOADPATH",        (APTR)QueryAUploadPath,
  167.     "ADOWNLOADPATH",    (APTR)QueryADownloadPath,
  168.     "BUPLOADPATH",        (APTR)QueryBUploadPath,
  169.     "BDOWNLOADPATH",    (APTR)QueryBDownloadPath,
  170.     "CAPTUREPATH",        (APTR)QueryCapturePath,
  171.     "LOGFILE",        (APTR)QueryLogFile,
  172.     "EDITOR",        (APTR)QueryEditor,
  173.     "BEEPSOUND",        (APTR)QueryBeepSound,
  174.     "CAPTURESTATE",        (APTR)QueryCaptureState,
  175.     "DOWNLOADS",        (APTR)QueryDownloads,
  176.  
  177.     /* Added in revision 1.8b */
  178.  
  179.     "SPEECHFILE",        (APTR)QuerySpeechFile,
  180.     "SCREENADDRESS",    (APTR)QueryScreenAddress,
  181.     "SPEECHRATE",        (APTR)QuerySpeechRate,
  182.     "SPEECHPITCH",        (APTR)QuerySpeechPitch,
  183.     "SPEECHFREQUENCY",    (APTR)QuerySpeechFrequency,
  184.     "SPEECHVOLUME",        (APTR)QuerySpeechVolume,
  185.     "SPEECHSEX",        (APTR)QuerySpeechSex,
  186.     "SPEECH",        (APTR)QuerySpeech
  187. };
  188.  
  189.     /* Any options which are to be set using the `SET' command
  190.      * are stored in the following list (these commands are
  191.      * handled synchronously).
  192.      */
  193.  
  194. #define NUMSETS        71
  195.  
  196.     /* How many set commands require more parameters? */
  197.  
  198. #define SETMOREPARAMS    6
  199.  
  200. STATIC struct CommandStruct SetCommands[NUMSETS] =
  201. {
  202.     /* The first five commands require more than
  203.      * one calling parameter and are handled
  204.      * differently (as compared to the other
  205.      * set commands).
  206.      */
  207.  
  208.     "MACRO",        (APTR)RexxSetMacro,
  209.     "COLOUR",        (APTR)RexxSetColour,
  210.     "COLOR",        (APTR)RexxSetColour,
  211.     "SCREEN",        (APTR)RexxSetScreen,
  212.     "BELL",            (APTR)RexxSetBell,
  213.     "TIMEOUT",        (APTR)RexxSetTimeout,
  214.  
  215.     "BAUDRATE",        (APTR)RexxSetBaud,
  216.     "BITSPERCHAR",        (APTR)RexxSetDataBits,
  217.     "PARITY",        (APTR)RexxSetParity,
  218.     "STOPBITS",        (APTR)RexxSetStopBits,
  219.     "HANDSHAKING",        (APTR)RexxSetHandshaking,
  220.     "DUPLEX",        (APTR)RexxSetDuplex,
  221.     "HIGHSPEED",        (APTR)RexxSetHighSpeed,
  222.     "BREAKLENGTH",        (APTR)RexxSetBreakLength,
  223.     "SERIALDEVICE",        (APTR)RexxSetSerialDevice,
  224.     "UNITNUMBER",        (APTR)RexxSetUnitNumber,
  225.     "MODEMINIT",        (APTR)RexxSetModemInit,
  226.     "MODEMEXIT",        (APTR)RexxSetModemExit,
  227.     "DIALPREFIX",        (APTR)RexxSetDialPrefix,
  228.     "REDIALDELAY",        (APTR)RexxSetRedialDelay,
  229.     "DIALRETRIES",        (APTR)RexxSetDialRetries,
  230.     "DIALTIMEOUT",        (APTR)RexxSetDialTimeout,
  231.     "CONNECTAUTOBAUD",    (APTR)RexxSetConnectAutoBaud,
  232.     "NOCARRIER",        (APTR)RexxSetNoCarrier,
  233.     "CONNECT",        (APTR)RexxSetConnect,
  234.     "VOICE",        (APTR)RexxSetVoice,
  235.     "RING",            (APTR)RexxSetRing,
  236.     "BUSY",            (APTR)RexxSetBusy,
  237.     "SCREENMODE",        (APTR)RexxSetScreenMode,
  238.     "FILTER",        (APTR)RexxSetFilter,
  239.     "BACKSPACE",        (APTR)RexxSetBackspace,
  240.     "CR",            (APTR)RexxSetCR,
  241.     "LF",            (APTR)RexxSetLF,
  242.     "EIGHTYCOLUMNS",    (APTR)RexxSet80Columns,
  243.     "COLOURMODE",        (APTR)RexxSetColourMode,
  244.     "COLORMODE",        (APTR)RexxSetColourMode,
  245.     "EMULATION",        (APTR)RexxSetEmulation,
  246.     "FONT",            (APTR)RexxSetFont,
  247.     "STARTUP",        (APTR)RexxSetStartup,
  248.     "PROTOCOL",        (APTR)RexxSetProtocol,
  249.     "PROTOCOLOPTIONS",    (APTR)RexxSetProtocolOptions,
  250.     "REQUESTERS",        (APTR)RexxSetRequesters,
  251.     "SERIAL",        (APTR)RexxSetSerial,
  252.  
  253.     /* Added in revision 1.6 */
  254.  
  255.     "MODEMHANGUP",        (APTR)RexxSetModemHangup,
  256.     "AUTOCAPTURE",        (APTR)RexxSetAutoCapture,
  257.     "LOGACTIONS",        (APTR)RexxSetLogActions,
  258.     "BLINKING",        (APTR)RexxSetBlinking,
  259.     "CURSORMODE",        (APTR)RexxSetCursorMode,
  260.     "FONTSCALE",        (APTR)RexxSetFontScale,
  261.     "SMOOTHSCROLL",        (APTR)RexxSetJumpScroll,
  262.     "CHARACTERWRAP",    (APTR)RexxSetCharacterWrap,
  263.     "CURSORWRAP",        (APTR)RexxSetCursorWrap,
  264.     "NEWLINEMODE",        (APTR)RexxSetNewLine,
  265.     "INSERTMODE",        (APTR)RexxSetInsert,
  266.     "NUMERICMODE",        (APTR)RexxSetNumeric,
  267.     "DEFAULTSTORE",        (APTR)RexxSetDefaultStore,
  268.     "TUPLOADPATH",        (APTR)RexxSetTUploadPath,
  269.     "TDOWNLOADPATH",    (APTR)RexxSetTDownloadPath,
  270.     "AUPLOADPATH",        (APTR)RexxSetAUploadPath,
  271.     "ADOWNLOADPATH",    (APTR)RexxSetADownloadPath,
  272.     "BUPLOADPATH",        (APTR)RexxSetBUploadPath,
  273.     "BDOWNLOADPATH",    (APTR)RexxSetBDownloadPath,
  274.     "CAPTUREPATH",        (APTR)RexxSetCapturePath,
  275.     "LOGFILE",        (APTR)RexxSetLogFile,
  276.     "EDITOR",        (APTR)RexxSetEditor,
  277.  
  278.     /* Added in revision 1.8b */
  279.  
  280.     "SPEECHRATE",        (APTR)RexxSetSpeechRate,
  281.     "SPEECHPITCH",        (APTR)RexxSetSpeechPitch,
  282.     "SPEECHFREQUENCY",    (APTR)RexxSetSpeechFrequency,
  283.     "SPEECHVOLUME",        (APTR)RexxSetSpeechVolume,
  284.     "SPEECHSEX",        (APTR)RexxSetSpeechSex,
  285.     "SPEECH",        (APTR)RexxSetSpeech
  286. };
  287.  
  288.     /* The following list contains only synchronous commands
  289.      * the rexx server passes to the term main process.
  290.      */
  291.  
  292. #define NUMREXX        35
  293.  
  294.     /* How many commands require more parameters. */
  295.  
  296. #define REXXMOREPARAMS    8
  297.  
  298. struct CommandStruct RexxCommands[NUMREXX] =
  299. {
  300.     /* The first five commands require more than
  301.      * one calling parameter.
  302.      */
  303.  
  304.     "BUFFER",        (APTR)RexxBuffer,
  305.     "CAPTURE",        (APTR)RexxCapture,
  306.     "CONFIG",        (APTR)RexxConfig,
  307.     "MACROS",        (APTR)RexxMacros,
  308.     "SPEECH",        (APTR)RexxSpeech,
  309.     "PHONE",        (APTR)RexxPhone,
  310.     "DELAY",        (APTR)RexxDelay,
  311.     "WAITSTRING",        (APTR)RexxWaitString,
  312.  
  313.     "PRINTER",        (APTR)RexxPrinter,
  314.     "BEEP",            (APTR)DoSomeBeep,
  315.     "BREAK",        (APTR)RexxBreak,
  316.     "BUPLOAD",        (APTR)RexxBUpload,
  317.     "BDOWNLOAD",        (APTR)RexxBDownload,
  318.     "CLEARSCREEN",        (APTR)RexxClearScreen,
  319.     "COMMAND",        (APTR)RexxCommand,
  320.     "DIAL",            (APTR)RexxDial,
  321.     "GETSTRING",        (APTR)RexxGetString,
  322.     "HANGUP",        (APTR)RexxHangUp,
  323.     "INPUT",        (APTR)RexxInput,
  324.     "MESSAGE",        (APTR)RexxMessage,
  325.     "RESETSTYLES",        (APTR)RexxResetStyles,
  326.     "SAVEILBM",        (APTR)RexxSaveILBM,
  327.     "TUPLOAD",        (APTR)RexxTUpload,
  328.     "TDOWNLOAD",        (APTR)RexxTDownload,
  329.     "WRITE",        (APTR)RexxWrite,
  330.     "PUTCLIP",        (APTR)RexxPutClip,
  331.     "GETCLIP",        (APTR)RexxGetClip,
  332.  
  333.     /* Added in revision 1.6 */
  334.  
  335.     "FIRSTDOWNLOAD",    (APTR)RexxFirstDownload,
  336.     "NEXTDOWNLOAD",        (APTR)RexxNextDownload,
  337.     "LASTDOWNLOAD",        (APTR)RexxLastDownload,
  338.  
  339.     /* Added in revision 1.8a */
  340.  
  341.     "TONEDIAL",        (APTR)RexxToneDial,
  342.  
  343.     /* Added in revision 1.8b */
  344.  
  345.     "SIMPLEREQUEST",    (APTR)RexxSimpleRequest,
  346.     "TWOGADREQUEST",    (APTR)RexxTwoGadRequest,
  347.     "FILEREQUEST",        (APTR)RexxFileRequest,
  348.  
  349.     "SPEAK",        (APTR)RexxSpeak
  350. };
  351.  
  352.     /* A global error code and a global input timeout. */
  353.  
  354. STATIC LONG RexxRes1,RexxGlobalTimeout;
  355.  
  356.     /* The names of the 16 display mode IDs in abbreviated
  357.      * form.
  358.      */
  359.  
  360. STATIC UBYTE *ConfigDisplayNames[16] =
  361. {
  362.     "HIRES",
  363.     "HIRESLACE",
  364.     "SUPERHIRES",
  365.     "SUPERHIRESLACE",
  366.     "PRODUCT",
  367.     "PRODUCTLACE",
  368.  
  369.     "PALHIRES",
  370.     "PALHIRESLACE",
  371.     "PALSUPERHIRES",
  372.     "PALSUPERHIRESLACE",
  373.  
  374.     "NTSCHIRES",
  375.     "NTSCHIRESLACE",
  376.     "NTSCSUPERHIRES",
  377.     "NTSCSUPERHIRESLACE",
  378.  
  379.     "A2024TENHZ",
  380.     "A2024FIFTEENHZ"
  381. };
  382.  
  383.     /* The global duplex modes in abbreviated form. */
  384.  
  385. STATIC UBYTE *ConfigDuplex[2] =
  386. {
  387.     "FULL",
  388.     "HALF"
  389. };
  390.  
  391.     /* The global handshake modes in abbreviated form. */
  392.  
  393. STATIC UBYTE *ConfigHandshaking[3] =
  394. {
  395.     "XONOFF",
  396.     "RTSCTS",
  397.     "NONE"
  398. };
  399.  
  400.     /* The global fonts in abbreviated form. */
  401.  
  402. STATIC UBYTE *ConfigFont[2] =
  403. {
  404.     "TOPAZ",
  405.     "IBM"
  406. };
  407.  
  408.     /* The global colour modes in abbreviated form. */
  409.  
  410. STATIC UBYTE *ConfigColour[4] =
  411. {
  412.     "AMIGA",
  413.     "EIGHT",
  414.     "SIXTEEN",
  415.     "MONO"
  416. };
  417.  
  418.     /* The emulation types in abbreviated form. */
  419.  
  420. STATIC UBYTE *ConfigEmulation[3] =
  421. {
  422.     "ANSIVT",
  423.     "ATOMIC",
  424.     "TTY"
  425. };
  426.  
  427.     /* The global parity settings in abbreviated form. */
  428.  
  429. STATIC UBYTE *ConfigParity[5] =
  430. {
  431.     "NONE",
  432.     "EVEN",
  433.     "ODD",
  434.     "MARK",
  435.     "SPACE"
  436. };
  437.  
  438.     /* The global term status modes in abbreviated form. */
  439.  
  440. STATIC UBYTE *ConfigStatus[7] =
  441. {
  442.     "READY",
  443.     "HOLDING",
  444.     "DIALING",
  445.     "UPLOAD",
  446.     "DOWNLOAD",
  447.     "BREAKING",
  448.     "HANGUP"
  449. };
  450.  
  451.     /* Two boolean identifiers. */
  452.  
  453. STATIC UBYTE *Booleans[2] =
  454. {
  455.     "OFF",
  456.     "ON"
  457. };
  458.  
  459. STATIC UBYTE *KeyModes[2] =
  460. {
  461.     "STANDARD",
  462.     "APPLICATION"
  463. };
  464.  
  465. STATIC UBYTE *FontSizes[5] =
  466. {
  467.     "NORMAL",
  468.     "HIGHTOP",
  469.     "HIGHBOTTOM",
  470.     "WIDE",
  471.     "HALF"
  472. };
  473.  
  474. STATIC UBYTE *Qualifiers[4] =
  475. {
  476.     "NONE",
  477.     "SHIFT",
  478.     "ALTERNATE",
  479.     "CONTROL"
  480. };
  481.  
  482.     /* SendRexxCommand():
  483.      *
  484.      *    Post a command to an ARexx port.
  485.      */
  486.  
  487. BYTE
  488. SendRexxCommand(struct MsgPort *HostPort,STRPTR CommandString,STRPTR FileExtension,STRPTR HostName)
  489. {
  490.     struct MsgPort    *RexxPort = (struct MsgPort *)FindPort(RXSDIR);
  491.     struct RexxMsg    *HostMessage;
  492.  
  493.     if(RexxPort)
  494.     {
  495.         if(!HostName)
  496.             HostName = (STRPTR)"";
  497.  
  498.         if(!FileExtension)
  499.             FileExtension = (STRPTR)"";
  500.  
  501.         if(HostMessage = CreateRexxMsg((struct MsgPort *)HostPort,FileExtension,HostName))
  502.         {
  503.             if(HostMessage -> rm_Args[0] = CreateArgstring(CommandString,strlen(CommandString)))
  504.             {
  505.                 HostMessage -> rm_Action = RXCOMM;
  506.  
  507.                 PutMsg(RexxPort,HostMessage);
  508.  
  509.                 return(TRUE);
  510.             }
  511.  
  512.             DeleteRexxMsg(HostMessage);
  513.         }
  514.  
  515.         MyEasyRequest(Window,"`term' has a problem:\nCould not send rexx message!","Continue");
  516.  
  517.         return(FALSE);
  518.     }
  519.     else
  520.         MyEasyRequest(Window,"`term' has a problem:\nThe ARexx server is not running!","Continue");
  521. }
  522.  
  523.     /* FreeRexxCommand(struct RexxMsg *RexxMessage):
  524.      *
  525.      *    Free the contents of a RexxMsg.
  526.      */
  527.  
  528. VOID
  529. FreeRexxCommand(struct RexxMsg *RexxMessage)
  530. {
  531.     if(RexxMessage -> rm_Args[0])
  532.         DeleteArgstring(RexxMessage -> rm_Args[0]);
  533.  
  534.     DeleteRexxMsg(RexxMessage);
  535. }
  536.  
  537.     /* ReplyRexxCommand():
  538.      *
  539.      *    Reply a command request the rexx server - or someone else -
  540.      *    has passed to us.
  541.      */
  542.  
  543. VOID
  544. ReplyRexxCommand(struct RexxMsg *RexxMessage,LONG Primary,LONG Secondary,STRPTR Result)
  545. {
  546.     if(Secondary == NULL && (RexxMessage -> rm_Action & RXFF_RESULT))
  547.     {
  548.         if(Result)
  549.         {
  550.             if(Result[0])
  551.                 Secondary = (LONG)CreateArgstring(Result,strlen(Result));
  552.         }
  553.     }
  554.  
  555.     RexxMessage -> rm_Result1 = Primary;
  556.     RexxMessage -> rm_Result2 = Secondary;
  557.  
  558.     ReplyMsg(RexxMessage);
  559. }
  560.  
  561.     /* IsReallySpace(UBYTE c):
  562.      *
  563.      *    Return if the character passed to this routine is some
  564.      *    kind of blank space.
  565.      */
  566.  
  567. STATIC BYTE
  568. IsReallySpace(UBYTE c)
  569. {
  570.     if((c >= 13 && c <= 17) || c == 32)
  571.         return(TRUE);
  572.     else
  573.         return(FALSE);
  574. }
  575.  
  576.     /* GetToken():
  577.      *
  578.      *    Parse a string for a token (typically used for
  579.      *    rexx message parsing).
  580.      */
  581.  
  582. STRPTR
  583. GetToken(STRPTR String,LONG *StartChar,STRPTR AuxBuff,LONG MaxLength)
  584. {
  585.     WORD    i,StrEnd = 0,MaxPos = strlen(String);
  586.     BYTE    Filter = FALSE;
  587.     UBYTE    Brace = 0;
  588.  
  589.     if(MaxPos >= MaxLength + *StartChar)
  590.         MaxPos = MaxLength + *StartChar - 1;
  591.  
  592.     if(*StartChar <= strlen(String) - 1 && String && String[0] && AuxBuff && MaxLength)
  593.     {
  594.         for(i = *StartChar ; i <= MaxPos ; i++)
  595.         {
  596.             if(!Filter)
  597.             {
  598.                 if(!StrEnd && IsReallySpace(String[i]))
  599.                 {
  600.                     while(IsReallySpace(String[i]) && i < MaxPos)
  601.                     {
  602.                         i++;
  603.  
  604.                         (*StartChar)++;
  605.                     }
  606.                 }
  607.             }
  608.  
  609.             if((!Filter && IsReallySpace(String[i])) || String[i] == 0)
  610.             {
  611.                 strncpy(AuxBuff,(String + *StartChar),StrEnd);
  612.                 AuxBuff[StrEnd] = 0;
  613.  
  614.                 (*StartChar) += StrEnd;
  615.  
  616.                 return(AuxBuff);
  617.             }
  618.  
  619.             if(String[i] == '\'' || String[i] == '\"')
  620.             {
  621.                 if(!Filter)
  622.                 {
  623.                     Brace = String[i];
  624.  
  625.                     Filter = TRUE;
  626.                 }
  627.                 else
  628.                 {
  629.                     if(String[i] == Brace)
  630.                         Filter = FALSE;
  631.                 }
  632.             }
  633.  
  634.             StrEnd++;
  635.         }
  636.     }
  637.  
  638.     return(NULL);
  639. }
  640.  
  641.     /* A bunch of single rexx server routines is to follow.
  642.      * Since there are pretty much of subroutines, I didn't
  643.      * necessarily make a comment on any (figure out yourself
  644.      * how they work :-)
  645.      */
  646.  
  647. UBYTE *
  648. QueryBaud()
  649. {
  650.     SPrintf(RexxTextBuffer,"%ld",Config . BaudRate);
  651.  
  652.     return(RexxTextBuffer);
  653. }
  654.  
  655. UBYTE *
  656. QueryDataBits()
  657. {
  658.     SPrintf(RexxTextBuffer,"%ld",Config . BitsPerChar);
  659.  
  660.     return(RexxTextBuffer);
  661. }
  662.  
  663. UBYTE *
  664. QueryParity()
  665. {
  666.     return(ConfigParity[Config . Parity]);
  667. }
  668.  
  669. UBYTE *
  670. QueryStopBits()
  671. {
  672.     SPrintf(RexxTextBuffer,"%ld",Config . StopBits);
  673.  
  674.     return(RexxTextBuffer);
  675. }
  676.  
  677. UBYTE *
  678. QueryHandshaking()
  679. {
  680.     return(ConfigHandshaking[Config . Handshaking]);
  681. }
  682.  
  683. UBYTE *
  684. QueryDuplex()
  685. {
  686.     return(ConfigDuplex[Config . Duplex]);
  687. }
  688.  
  689. UBYTE *
  690. QueryHighspeed()
  691. {
  692.     return(Booleans[Config . HighSpeed]);
  693. }
  694.  
  695. UBYTE *
  696. QueryBreakLength()
  697. {
  698.     SPrintf(RexxTextBuffer,"%ld",Config . BreakLength);
  699.  
  700.     return(RexxTextBuffer);
  701. }
  702.  
  703. UBYTE *
  704. QuerySerialDevice()
  705. {
  706.     return(Config . SerialDevice);
  707. }
  708.  
  709. UBYTE *
  710. QueryUnitNumber()
  711. {
  712.     SPrintf(RexxTextBuffer,"%ld",Config . UnitNumber);
  713.  
  714.     return(RexxTextBuffer);
  715. }
  716.  
  717. UBYTE *
  718. QueryModemInit()
  719. {
  720.     return(Config . ModemInit);
  721. }
  722.  
  723. UBYTE *
  724. QueryModemExit()
  725. {
  726.     return(Config . ModemExit);
  727. }
  728.  
  729. UBYTE *
  730. QueryDialPrefix()
  731. {
  732.     return(Config . DialPrefix);
  733. }
  734.  
  735. UBYTE *
  736. QueryRedialDelay()
  737. {
  738.     SPrintf(RexxTextBuffer,"%ld",Config . RedialDelay);
  739.  
  740.     return(RexxTextBuffer);
  741. }
  742.  
  743. UBYTE *
  744. QueryDialRetries()
  745. {
  746.     SPrintf(RexxTextBuffer,"%ld",Config . DialRetries);
  747.  
  748.     return(RexxTextBuffer);
  749. }
  750.  
  751. UBYTE *
  752. QueryDialTimeout()
  753. {
  754.     SPrintf(RexxTextBuffer,"%ld",Config . DialTimeout);
  755.  
  756.     return(RexxTextBuffer);
  757. }
  758.  
  759. UBYTE *
  760. QueryConnectAutoBaud()
  761. {
  762.     return(Booleans[Config . ConnectAutoBaud]);
  763. }
  764.  
  765. UBYTE *
  766. QueryNoCarrier()
  767. {
  768.     return(Config . NoCarrier);
  769. }
  770.  
  771. UBYTE *
  772. QueryConnect()
  773. {
  774.     return(Config . Connect);
  775. }
  776.  
  777. UBYTE *
  778. QueryVoice()
  779. {
  780.     return(Config . Voice);
  781. }
  782.  
  783. UBYTE *
  784. QueryRing()
  785. {
  786.     return(Config . Ring);
  787. }
  788.  
  789. UBYTE *
  790. QueryBusy()
  791. {
  792.     return(Config . Busy);
  793. }
  794.  
  795. UBYTE *
  796. QueryProtocol()
  797. {
  798.     return(Config . Protocol);
  799. }
  800.  
  801. UBYTE *
  802. QueryProtocolOptions()
  803. {
  804.     return(ProtocolOptsBuffer);
  805. }
  806.  
  807. UBYTE *
  808. QueryMacroFile()
  809. {
  810.     return(Config . MacroFile);
  811. }
  812.  
  813. UBYTE *
  814. QueryDisplay()
  815. {
  816.     WORD i;
  817.  
  818.     for(i = 0 ; i < 16 ; i++)
  819.         if(Config . DisplayMode == ModeID[i])
  820.             return(ConfigDisplayNames[i]);
  821.  
  822.     return(0);
  823. }
  824.  
  825. UBYTE *
  826. QueryPublicScreen()
  827. {
  828.     return(Booleans[Config . MakeScreenPublic]);
  829. }
  830.  
  831. UBYTE *
  832. QueryShanghai()
  833. {
  834.     return(Booleans[Config . ShanghaiWindows]);
  835. }
  836.  
  837. UBYTE *
  838. QueryCaptureFilter()
  839. {
  840.     return(Booleans[Config . HighSpeed]);
  841. }
  842.  
  843. UBYTE *
  844. QueryDSBackSpace()
  845. {
  846.     return(Booleans[Config . DestructiveBackspace]);
  847. }
  848.  
  849. UBYTE *
  850. QueryAudBell()
  851. {
  852.     return(Booleans[Config . AudibleBell]);
  853. }
  854.  
  855. UBYTE *
  856. QueryVisBell()
  857. {
  858.     return(Booleans[Config . VisibleBell]);
  859. }
  860.  
  861. UBYTE *
  862. QueryEightyColumns()
  863. {
  864.     return(Booleans[Config . EightyColumns != 0]);
  865. }
  866.  
  867. UBYTE *
  868. QuerySendCR()
  869. {
  870.     switch(Config . SendCR)
  871.     {
  872.         case CR_IGNORE:        return("IGNORE");
  873.         case CR_ASCR:        return("CR");
  874.         case CR_ASCRLF:        return("CRLF");
  875.     }
  876. }
  877.  
  878. UBYTE *
  879. QuerySendLF()
  880. {
  881.     switch(Config . SendLF)
  882.     {
  883.         case LF_IGNORE:        return("IGNORE");
  884.         case LF_ASLF:        return("LF");
  885.         case LF_ASLFCR:        return("LFCR");
  886.     }
  887. }
  888.  
  889. UBYTE *
  890. QueryColourMode()
  891. {
  892.     return(ConfigColour[Config . ColourMode]);
  893. }
  894.  
  895. UBYTE *
  896. QueryEmulation()
  897. {
  898.     return(ConfigEmulation[Config . Emulation]);
  899. }
  900.  
  901. UBYTE *
  902. QueryFont()
  903. {
  904.     return(ConfigFont[Config . Font]);
  905. }
  906.  
  907. UBYTE *
  908. QueryStatus()
  909. {
  910.     return(ConfigStatus[Status]);
  911. }
  912.  
  913. UBYTE *
  914. QuerySerial()
  915. {
  916.     return(Booleans[ReadPort ? 1 : 0]);
  917. }
  918.  
  919. UBYTE *
  920. QueryStartup()
  921. {
  922.     return(Config . StartupMacro);
  923. }
  924.  
  925. UBYTE *
  926. QueryRequesters()
  927. {
  928.     return((LONG)ThisProcess -> pr_WindowPtr == -1 ? Booleans[0] : Booleans[1]);
  929. }
  930.  
  931. UBYTE *
  932. QueryTimeout()
  933. {
  934.     SPrintf(RexxTextBuffer,"%ld",RexxGlobalTimeout);
  935.  
  936.     return(RexxTextBuffer);
  937. }
  938.  
  939. UBYTE *
  940. QueryLine()
  941. {
  942.     return(Booleans[Online]);
  943. }
  944.  
  945. UBYTE *
  946. QueryLines()
  947. {
  948.         /* Note: LastLine is the last accessible line (i.e. for a
  949.          *       24 line display, LastLine will be 23).
  950.          */
  951.  
  952.     SPrintf(RexxTextBuffer,"%ld",LastLine + 1);
  953.  
  954.     return(RexxTextBuffer);
  955. }
  956.  
  957. UBYTE *
  958. QueryColumns()
  959. {
  960.     SPrintf(RexxTextBuffer,"%ld",LastColumn);
  961.  
  962.     return(RexxTextBuffer);
  963. }
  964.  
  965. UBYTE *
  966. QueryCursor()
  967. {
  968.     SPrintf(RexxTextBuffer,"%ld %ld",CursorX,CursorY);
  969.  
  970.     return(RexxTextBuffer);
  971. }
  972.  
  973. UBYTE *
  974. QueryModemHangup()
  975. {
  976.     return(Config . ModemHangup);
  977. }
  978.  
  979. UBYTE *
  980. QueryAutoCapture()
  981. {
  982.     return(Booleans[Config . ConnectAutoCapture]);
  983. }
  984.  
  985. UBYTE *
  986. QueryLogActions()
  987. {
  988.     return(Booleans[Config . LogActions]);
  989. }
  990.  
  991. UBYTE *
  992. QueryBlinking()
  993. {
  994.     return(Booleans[Config . DisableBlinking ^ TRUE]);
  995. }
  996.  
  997. UBYTE *
  998. QueryCursorMode()
  999. {
  1000.     return(KeyModes[Config . CursorApp]);
  1001. }
  1002.  
  1003. UBYTE *
  1004. QueryFontScale()
  1005. {
  1006.     return(FontSizes[Config . FontScale]);
  1007. }
  1008.  
  1009. UBYTE *
  1010. QueryJumpScroll()
  1011. {
  1012.     return(Booleans[Config . JumpScroll ^ TRUE]);
  1013. }
  1014.  
  1015. UBYTE *
  1016. QueryCharacterWrap()
  1017. {
  1018.     return(Booleans[Config . AutoWrap]);
  1019. }
  1020.  
  1021. UBYTE *
  1022. QueryCursorWrap()
  1023. {
  1024.     return(Booleans[Config . CursorWrap]);
  1025. }
  1026.  
  1027. UBYTE *
  1028. QueryNewLine()
  1029. {
  1030.     return(Booleans[Config . NewLine]);
  1031. }
  1032.  
  1033. UBYTE *
  1034. QueryInsert()
  1035. {
  1036.     return(Booleans[Config . InsertChar]);
  1037. }
  1038.  
  1039. UBYTE *
  1040. QueryNumeric()
  1041. {
  1042.     return(KeyModes[Config . NumApp]);
  1043. }
  1044.  
  1045. UBYTE *
  1046. QueryDefaultStore()
  1047. {
  1048.     return(Config . DefaultStorage);
  1049. }
  1050.  
  1051. UBYTE *
  1052. QueryTUploadPath()
  1053. {
  1054.     return(Config . TextUploadPath);
  1055. }
  1056.  
  1057. UBYTE *
  1058. QueryTDownloadPath()
  1059. {
  1060.     return(Config . TextDownloadPath);
  1061. }
  1062.  
  1063. UBYTE *
  1064. QueryAUploadPath()
  1065. {
  1066.     return(Config . ASCIIUploadPath);
  1067. }
  1068.  
  1069. UBYTE *
  1070. QueryADownloadPath()
  1071. {
  1072.     return(Config . ASCIIDownloadPath);
  1073. }
  1074.  
  1075. UBYTE *
  1076. QueryBUploadPath()
  1077. {
  1078.     return(Config . BinaryUploadPath);
  1079. }
  1080.  
  1081. UBYTE *
  1082. QueryBDownloadPath()
  1083. {
  1084.     return(Config . BinaryDownloadPath);
  1085. }
  1086.  
  1087. UBYTE *
  1088. QueryCapturePath()
  1089. {
  1090.     return(Config . CapturePath);
  1091. }
  1092.  
  1093. UBYTE *
  1094. QueryLogFile()
  1095. {
  1096.     return(Config . LogFile);
  1097. }
  1098.  
  1099. UBYTE *
  1100. QueryEditor()
  1101. {
  1102.     return(Config . Editor);
  1103. }
  1104.  
  1105. UBYTE *
  1106. QueryBeepSound()
  1107. {
  1108.     return(Config . BeepSound);
  1109. }
  1110.  
  1111. UBYTE *
  1112. QueryCaptureState()
  1113. {
  1114.     RexxTextBuffer[0] = 0;
  1115.  
  1116.     if(PrinterCapture)
  1117.     {
  1118.         strcat(RexxTextBuffer,"PRINTER");
  1119.  
  1120.         if(FileCapture)
  1121.             strcat(RexxTextBuffer," FILE");
  1122.     }
  1123.     else
  1124.     {
  1125.         if(FileCapture)
  1126.             strcat(RexxTextBuffer,"FILE");
  1127.         else
  1128.             strcat(RexxTextBuffer,Booleans[0]);
  1129.     }        
  1130.  
  1131.     return(RexxTextBuffer);
  1132. }
  1133.  
  1134. UBYTE *
  1135. QueryDownloads()
  1136. {
  1137.     SPrintf(RexxTextBuffer,"%ld",DownloadLineCount);
  1138.  
  1139.     return(RexxTextBuffer);
  1140. }
  1141.  
  1142. UBYTE *
  1143. QueryScreenAddress()
  1144. {
  1145.     SPrintf(RexxTextBuffer,"%ld",Screen);
  1146.  
  1147.     return(RexxTextBuffer);
  1148. }
  1149.  
  1150. UBYTE *
  1151. QuerySpeechFile()
  1152. {
  1153.     return(LastSpeech);
  1154. }
  1155.  
  1156. UBYTE *
  1157. QuerySpeechRate()
  1158. {
  1159.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Rate);
  1160.  
  1161.     return(RexxTextBuffer);
  1162. }
  1163.  
  1164. UBYTE *
  1165. QuerySpeechPitch()
  1166. {
  1167.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Pitch);
  1168.  
  1169.     return(RexxTextBuffer);
  1170. }
  1171.  
  1172. UBYTE *
  1173. QuerySpeechFrequency()
  1174. {
  1175.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Frequency);
  1176.  
  1177.     return(RexxTextBuffer);
  1178. }
  1179.  
  1180. UBYTE *
  1181. QuerySpeechVolume()
  1182. {
  1183.     SPrintf(RexxTextBuffer,"%ld",SpeechConfig . Volume);
  1184.  
  1185.     return(RexxTextBuffer);
  1186. }
  1187.  
  1188. UBYTE *
  1189. QuerySpeechSex()
  1190. {
  1191.     return(SpeechConfig . Sex ? "FEMALE" : "MALE");
  1192. }
  1193.  
  1194. UBYTE *
  1195. QuerySpeech()
  1196. {
  1197.     return(Booleans[SpeechConfig . Enabled]);
  1198. }
  1199.  
  1200. VOID
  1201. RexxSetBaud(UBYTE *String)
  1202. {
  1203.     LONG Value = atol(String);
  1204.  
  1205.     if(Config . BaudRate != Value)
  1206.     {
  1207.         Config . BaudRate = Value;
  1208.  
  1209.         ResetSerial = TRUE;
  1210.     }
  1211. }
  1212.  
  1213. VOID
  1214. RexxSetDataBits(UBYTE *String)
  1215. {
  1216.     LONG Bits = atol(String);
  1217.  
  1218.     if(Bits == 7 || Bits == 8)
  1219.     {
  1220.         if(Config . BitsPerChar != Bits)
  1221.         {
  1222.             Config . BitsPerChar = Bits;
  1223.  
  1224.             ResetSerial = TRUE;
  1225.         }
  1226.     }
  1227.     else
  1228.         RexxRes1 = RC_ERROR;
  1229. }
  1230.  
  1231. VOID
  1232. RexxSetParity(UBYTE *String)
  1233. {
  1234.     WORD i;
  1235.  
  1236.     for(i = 0 ; i < 5 ; i++)
  1237.     {
  1238.         if(!Stricmp(String,ConfigParity[i]))
  1239.         {
  1240.             if(Config . Parity != i)
  1241.             {
  1242.                 Config . Parity = i;
  1243.  
  1244.                 ResetSerial = TRUE;
  1245.             }
  1246.  
  1247.             break;
  1248.         }
  1249.     }
  1250. }
  1251.  
  1252. VOID
  1253. RexxSetStopBits(UBYTE *String)
  1254. {
  1255.     LONG Bits = atol(String);
  1256.  
  1257.     if(Bits == 1 || Bits == 2)
  1258.     {
  1259.         if(Config . StopBits != Bits)
  1260.         {
  1261.             Config . StopBits = Bits;
  1262.  
  1263.             ResetSerial = TRUE;
  1264.         }
  1265.     }
  1266.     else
  1267.         RexxRes1 = RC_ERROR;
  1268. }
  1269.  
  1270. VOID
  1271. RexxSetHandshaking(UBYTE *String)
  1272. {
  1273.     WORD i;
  1274.  
  1275.     for(i = 0 ; i < 3 ; i++)
  1276.     {
  1277.         if(!Stricmp(String,ConfigHandshaking[i]))
  1278.         {
  1279.             if(Config . Handshaking != i)
  1280.             {
  1281.                 Config . Handshaking = i;
  1282.  
  1283.                 ResetSerial = TRUE;
  1284.             }
  1285.  
  1286.             break;
  1287.         }
  1288.     }
  1289. }
  1290.  
  1291. VOID
  1292. RexxSetDuplex(UBYTE *String)
  1293. {
  1294.     WORD i;
  1295.  
  1296.     for(i = 0 ; i < 2 ; i++)
  1297.     {
  1298.         if(!Stricmp(String,ConfigDuplex[i]))
  1299.         {
  1300.             Config . Duplex = i;
  1301.  
  1302.             break;
  1303.         }
  1304.     }
  1305. }
  1306.  
  1307. VOID
  1308. RexxSetHighSpeed(UBYTE *String)
  1309. {
  1310.     WORD i;
  1311.  
  1312.     for(i = 0 ; i < 2 ; i++)
  1313.     {
  1314.         if(!Stricmp(String,Booleans[i]))
  1315.         {
  1316.             if(Config . HighSpeed != i)
  1317.             {
  1318.                 Config . HighSpeed = i;
  1319.  
  1320.                 ResetSerial = TRUE;
  1321.             }
  1322.  
  1323.             break;
  1324.         }
  1325.     }
  1326. }
  1327.  
  1328. VOID
  1329. RexxSetBreakLength(UBYTE *String)
  1330. {
  1331.     LONG Value = atol(String);
  1332.  
  1333.     if(Config . BreakLength != Value)
  1334.     {
  1335.         Config . BreakLength = Value;
  1336.  
  1337.         ResetSerial = TRUE;
  1338.     }
  1339. }
  1340.  
  1341. VOID
  1342. RexxSetSerialDevice(UBYTE *String)
  1343. {
  1344.     if(strcmp(Config . SerialDevice,String))
  1345.     {
  1346.         strcpy(Config . SerialDevice,String);
  1347.  
  1348.         ResetSerial = TRUE;
  1349.     }
  1350. }
  1351.  
  1352. VOID
  1353. RexxSetUnitNumber(UBYTE *String)
  1354. {
  1355.     LONG Value = atol(String);
  1356.  
  1357.     if(Config . UnitNumber != Value)
  1358.     {
  1359.         Config . UnitNumber = Value;
  1360.  
  1361.         ResetSerial = TRUE;
  1362.     }
  1363. }
  1364.  
  1365. VOID
  1366. RexxSetModemInit(UBYTE *String)
  1367. {
  1368.     strcpy(Config . ModemInit,String);
  1369. }
  1370.  
  1371. VOID
  1372. RexxSetModemExit(UBYTE *String)
  1373. {
  1374.     strcpy(Config . ModemExit,String);
  1375. }
  1376.  
  1377. VOID
  1378. RexxSetDialPrefix(UBYTE *String)
  1379. {
  1380.     strcpy(Config . DialPrefix,String);
  1381. }
  1382.  
  1383. VOID
  1384. RexxSetRedialDelay(UBYTE *String)
  1385. {
  1386.     Config . RedialDelay = atol(String);
  1387. }
  1388.  
  1389. VOID
  1390. RexxSetDialRetries(UBYTE *String)
  1391. {
  1392.     Config . DialRetries = atol(String);
  1393. }
  1394.  
  1395. VOID
  1396. RexxSetDialTimeout(UBYTE *String)
  1397. {
  1398.     Config . DialTimeout = atol(String);
  1399. }
  1400.  
  1401. VOID
  1402. RexxSetConnectAutoBaud(UBYTE *String)
  1403. {
  1404.     WORD i;
  1405.  
  1406.     for(i = 0 ; i < 2 ; i++)
  1407.     {
  1408.         if(!Stricmp(String,Booleans[i]))
  1409.         {
  1410.             Config . ConnectAutoBaud = i;
  1411.  
  1412.             break;
  1413.         }
  1414.     }
  1415. }
  1416.  
  1417. VOID
  1418. RexxSetNoCarrier(UBYTE *String)
  1419. {
  1420.     strcpy(Config . NoCarrier,String);
  1421. }
  1422.  
  1423. VOID
  1424. RexxSetConnect(UBYTE *String)
  1425. {
  1426.     strcpy(Config . Connect,String);
  1427. }
  1428.  
  1429. VOID
  1430. RexxSetVoice(UBYTE *String)
  1431. {
  1432.     strcpy(Config . Voice,String);
  1433. }
  1434.  
  1435. VOID
  1436. RexxSetRing(UBYTE *String)
  1437. {
  1438.     strcpy(Config . Ring,String);
  1439. }
  1440.  
  1441. VOID
  1442. RexxSetBusy(UBYTE *String)
  1443. {
  1444.     strcpy(Config . Busy,String);
  1445. }
  1446.  
  1447. VOID
  1448. RexxSetScreenMode(UBYTE *String)
  1449. {
  1450.     WORD i;
  1451.  
  1452.     for(i = 0 ; i < 16 ; i++)
  1453.     {
  1454.         if(!Stricmp(ConfigDisplayNames[i],String))
  1455.         {
  1456.             if(!ModeNotAvailable(ModeID[i]))
  1457.             {
  1458.                 if(Config . DisplayMode != ModeID[i])
  1459.                 {
  1460.                     BYTE Limited;
  1461.  
  1462.                     if(Config . ColourMode == COLOUR_EIGHT || Config . ColourMode == COLOUR_SIXTEEN)
  1463.                         Limited = TRUE;
  1464.                     else
  1465.                         Limited = FALSE;
  1466.  
  1467.                     if(!Limited && ((ModeID[i] & ~MONITOR_ID_MASK) != HIRES_KEY) && ((ModeID[i] & ~MONITOR_ID_MASK) != HIRESLACE_KEY))
  1468.                     {
  1469.                         Config . DisplayMode = ModeID[i];
  1470.  
  1471.                         ResetDisplay = TRUE;
  1472.                     }
  1473.                 }
  1474.             }
  1475.  
  1476.             break;
  1477.         }
  1478.     }
  1479. }
  1480.  
  1481. VOID
  1482. RexxSetFilter(UBYTE *String)
  1483. {
  1484.     WORD i;
  1485.  
  1486.     for(i = 0 ; i < 2 ; i++)
  1487.     {
  1488.         if(!Stricmp(String,Booleans[i]))
  1489.         {
  1490.             Config . CaptureFilter = i;
  1491.  
  1492.             break;
  1493.         }
  1494.     }
  1495. }
  1496.  
  1497. VOID
  1498. RexxSetBackspace(UBYTE *String)
  1499. {
  1500.     WORD i;
  1501.  
  1502.     for(i = 0 ; i < 2 ; i++)
  1503.     {
  1504.         if(!Stricmp(String,Booleans[i]))
  1505.         {
  1506.             Config . DestructiveBackspace = i;
  1507.  
  1508.             break;
  1509.         }
  1510.     }
  1511. }
  1512.  
  1513. VOID
  1514. RexxSetCR(UBYTE *String)
  1515. {
  1516.     if(!Stricmp(String,"IGNORE"))
  1517.         Config . SendCR = CR_IGNORE;
  1518.  
  1519.     if(!Stricmp(String,"CR"))
  1520.         Config . SendCR = CR_ASCR;
  1521.  
  1522.     if(!Stricmp(String,"CRLF"))
  1523.         Config . SendCR = CR_ASCRLF;
  1524. }
  1525.  
  1526. VOID
  1527. RexxSetLF(UBYTE *String)
  1528. {
  1529.     if(!Stricmp(String,"IGNORE"))
  1530.         Config . SendLF = LF_IGNORE;
  1531.  
  1532.     if(!Stricmp(String,"LF"))
  1533.         Config . SendLF = LF_ASLF;
  1534.  
  1535.     if(!Stricmp(String,"LFCR"))
  1536.         Config . SendLF = LF_ASLFCR;
  1537. }
  1538.  
  1539. VOID
  1540. RexxSet80Columns(UBYTE *String)
  1541. {
  1542.     WORD i;
  1543.  
  1544.     for(i = 0 ; i < 2 ; i++)
  1545.     {
  1546.         if(!Stricmp(String,Booleans[i]))
  1547.         {
  1548.             Config . EightyColumns = i;
  1549.  
  1550.             ConfigSetup();
  1551.  
  1552.             break;
  1553.         }
  1554.     }
  1555. }
  1556.  
  1557. VOID
  1558. RexxSetColourMode(UBYTE *String)
  1559. {
  1560.     WORD i;
  1561.  
  1562.     for(i = 0 ; i < 4 ; i++)
  1563.     {
  1564.         if(!Stricmp(ConfigColour[i],String))
  1565.         {
  1566.             if(i != Config . ColourMode)
  1567.             {
  1568.                 BYTE Limited;
  1569.  
  1570.                 switch(Config . DisplayMode & ~MONITOR_ID_MASK)
  1571.                 {
  1572.                     case HIRES_KEY:
  1573.                     case HIRESLACE_KEY:    Limited = FALSE;
  1574.                                 break;
  1575.  
  1576.                     default:        Limited = TRUE;
  1577.                                 break;
  1578.                 }
  1579.  
  1580.                 if(Config . Emulation == EMULATION_ATOMIC && i > COLOUR_AMIGA && i < COLOUR_MONO)
  1581.                     Config . Emulation = EMULATION_ANSIVT100;
  1582.  
  1583.                 if(Limited && i != COLOUR_AMIGA && i != COLOUR_MONO)
  1584.                 {
  1585.                     if(Config . DisplayMode & LACE)
  1586.                         Config . DisplayMode = DEFAULT_MONITOR_ID|HIRESLACE_KEY;
  1587.                     else
  1588.                         Config . DisplayMode = DEFAULT_MONITOR_ID|HIRES_KEY;
  1589.                 }
  1590.  
  1591.                 Config . ColourMode = i;
  1592.  
  1593.                 ResetDisplay = TRUE;
  1594.             }
  1595.  
  1596.             break;
  1597.         }
  1598.     }
  1599. }
  1600.  
  1601. VOID
  1602. RexxSetEmulation(UBYTE *String)
  1603. {
  1604.     WORD i;
  1605.  
  1606.     for(i = 0 ; i < 3 ; i++)
  1607.     {
  1608.         if(!Stricmp(String,ConfigEmulation[i]))
  1609.         {
  1610.             if(Config . Emulation != i)
  1611.             {
  1612.                 Config . Emulation = i;
  1613.  
  1614.                 ResetDisplay = TRUE;
  1615.             }
  1616.  
  1617.             break;
  1618.         }
  1619.     }
  1620. }
  1621.  
  1622. VOID
  1623. RexxSetStartup(UBYTE *String)
  1624. {
  1625.     strcpy(Config . StartupMacro,String);
  1626. }
  1627.  
  1628. VOID
  1629. RexxSetFont(UBYTE *String)
  1630. {
  1631.     WORD i;
  1632.  
  1633.     for(i = 0 ; i < 2 ; i++)
  1634.     {
  1635.         if(!Stricmp(String,ConfigFont[i]))
  1636.         {
  1637.             if(Config . Font != i)
  1638.             {
  1639.                 Config . Font = i;
  1640.  
  1641.                 if(Config . Font == FONT_TOPAZ)
  1642.                     SetFont(RPort,Topaz);
  1643.                 else
  1644.                 {
  1645.                     if(IBM)
  1646.                         SetFont(RPort,IBM);
  1647.                 }
  1648.             }
  1649.  
  1650.             break;
  1651.         }
  1652.     }
  1653. }
  1654.  
  1655. VOID
  1656. RexxSetProtocol(UBYTE *String)
  1657. {
  1658.     if(Stricmp(LastXprLibrary,String))
  1659.     {
  1660.         UBYTE Name[80];
  1661.  
  1662.         WORD i;
  1663.  
  1664.         for(i = 0 ; i < strlen(String) ; i++)
  1665.             Name[i] = ToLower(String[i]);
  1666.  
  1667.         Name[i] = 0;
  1668.  
  1669.         strcpy(LastXprLibrary,Name);
  1670.  
  1671.         strcpy(Config . Protocol,LastXprLibrary);
  1672.  
  1673.         ProtocolSetup();
  1674.     }
  1675. }
  1676.  
  1677. VOID
  1678. RexxSetProtocolOptions(UBYTE *String)
  1679. {
  1680.     if(XProtocolBase)
  1681.     {
  1682.         if(Stricmp(ProtocolOptsBuffer,String))
  1683.         {
  1684.             strcpy(ProtocolOptsBuffer,String);
  1685.  
  1686.             XprIO -> xpr_filename = ProtocolOptsBuffer;
  1687.  
  1688.             TransferBits = XProtocolSetup(XprIO);
  1689.  
  1690.             if(!(TransferBits & XPRS_SUCCESS))
  1691.             {
  1692.                 CloseLibrary(XProtocolBase);
  1693.  
  1694.                 XProtocolBase = NULL;
  1695.  
  1696.                 LastXprLibrary[0] = 0;
  1697.  
  1698.                 TransferBits = 0;
  1699.  
  1700.                 RexxRes1 = RC_ERROR;
  1701.             }
  1702.         }
  1703.     }
  1704. }
  1705.  
  1706. VOID
  1707. RexxSetMacro(UBYTE *String)
  1708. {
  1709.     UBYTE Arg1[40],Arg2[40],Arg3[256];
  1710.     LONG ArgCount,i,Qualifier = -1;
  1711.  
  1712.     Arg1[0] = Arg2[0] = Arg3[0] = 0;
  1713.     ArgCount = 0;
  1714.  
  1715.     GetToken(String,&ArgCount,Arg1,40);
  1716.     GetToken(String,&ArgCount,Arg2,40);
  1717.     GetToken(String,&ArgCount,Arg3,256);
  1718.  
  1719.     for(i = 0 ; i < 4 ; i++)
  1720.     {
  1721.         if(!Stricmp(Qualifiers[i],Arg1))
  1722.         {
  1723.             Qualifier = i;
  1724.             break;
  1725.         }
  1726.     }
  1727.  
  1728.     if(Qualifier != -1)
  1729.     {
  1730.         if(Arg2[0] >= '0' && Arg2[0] <= '9')
  1731.             strcpy(MacroKeys -> Keys[Qualifier][Arg2[0] - '0'],Arg3);
  1732.         else
  1733.             RexxRes1 = RC_ERROR;
  1734.     }
  1735.     else
  1736.         RexxRes1 = RC_ERROR;
  1737. }
  1738.  
  1739. VOID
  1740. RexxSetColour(UBYTE *String)
  1741. {
  1742.     UBYTE Arg1[20],Arg2[20];
  1743.     LONG ArgCount;
  1744.  
  1745.     Arg1[0] = Arg2[0] = 0;
  1746.     ArgCount = 0;
  1747.  
  1748.     GetToken(String,&ArgCount,Arg1,20);
  1749.     GetToken(String,&ArgCount,Arg2,20);
  1750.  
  1751.     if(Arg1[0] && Arg2[0])
  1752.     {
  1753.         LONG Colour,Value;
  1754.  
  1755.         Colour    = atol(Arg1);
  1756.         Value    = ahtoi(Arg2);
  1757.  
  1758.         if(Colour >= 0 && Colour < (1 << (Config . ColourMode == COLOUR_EIGHT ? 3 : Screen -> RastPort . BitMap -> Depth)))
  1759.         {
  1760.             Config . Colours[Colour] = Value;
  1761.  
  1762.             if(Config . ColourMode == COLOUR_AMIGA && Config . Emulation == EMULATION_ANSIVT100)
  1763.             {
  1764.                 if(Colour == 0)
  1765.                     BlinkColours[3] = Value;
  1766.  
  1767.                 if(Colour != 3)
  1768.                     BlinkColours[Colour] = Value;
  1769.             }
  1770.             else
  1771.             {
  1772.                 if(Colour == 0 && Config . ColourMode == COLOUR_EIGHT && Config . Emulation == EMULATION_ANSIVT100)
  1773.                 {
  1774.                     WORD i;
  1775.  
  1776.                     for(i = 8 ; i < 16 ; i++)
  1777.                         BlinkColours[i] = Value;
  1778.                 }
  1779.                 else
  1780.                     BlinkColours[Colour] = Value;
  1781.             }
  1782.  
  1783.             LoadRGB4(VPort,&Config . Colours[0],(1 << Screen -> RastPort . BitMap -> Depth));
  1784.         }
  1785.         else
  1786.             RexxRes1 = RC_ERROR;
  1787.     }
  1788.     else
  1789.         RexxRes1 = RC_ERROR;
  1790. }
  1791.  
  1792. VOID
  1793. RexxSetScreen(UBYTE *String)
  1794. {
  1795.     UBYTE Arg1[20],Arg2[20];
  1796.     LONG ArgCount;
  1797.  
  1798.     Arg1[0] = Arg2[0] = 0;
  1799.     ArgCount = 0;
  1800.  
  1801.     GetToken(String,&ArgCount,Arg1,20);
  1802.     GetToken(String,&ArgCount,Arg2,20);
  1803.  
  1804.     Config . MakeScreenPublic    = FALSE;
  1805.     Config . ShanghaiWindows    = FALSE;
  1806.  
  1807.     if(!Stricmp(Arg1,"PUBLIC") || !Stricmp(Arg2,"PUBLIC"))
  1808.         Config . MakeScreenPublic = TRUE;
  1809.  
  1810.     if(!Stricmp(Arg1,"SHANGHAI") || !Stricmp(Arg2,"SHANGHAI"))
  1811.         Config . ShanghaiWindows = TRUE;
  1812.  
  1813.     PubScreenStuff();
  1814. }
  1815.  
  1816. VOID
  1817. RexxSetBell(UBYTE *String)
  1818. {
  1819.     UBYTE Arg1[20],Arg2[20];
  1820.     LONG ArgCount;
  1821.  
  1822.     Arg1[0] = Arg2[0] = 0;
  1823.     ArgCount = 0;
  1824.  
  1825.     GetToken(String,&ArgCount,Arg1,20);
  1826.     GetToken(String,&ArgCount,Arg2,20);
  1827.  
  1828.     Config . AudibleBell    = FALSE;
  1829.     Config . VisibleBell    = FALSE;
  1830.  
  1831.     if(!Stricmp(Arg1,"VISIBLE") || !Stricmp(Arg2,"VISIBLE"))
  1832.         Config . VisibleBell = TRUE;
  1833.  
  1834.     if(!Stricmp(Arg1,"AUDIBLE") || !Stricmp(Arg2,"AUDIBLE"))
  1835.         Config . AudibleBell = TRUE;
  1836. }
  1837.  
  1838. VOID
  1839. RexxSetRequesters(UBYTE *String)
  1840. {
  1841.     WORD i;
  1842.  
  1843.     for(i = 0 ; i < 2 ; i++)
  1844.     {
  1845.         if(!Stricmp(String,Booleans[i]))
  1846.         {
  1847.             ThisProcess -> pr_WindowPtr = (APTR)(i ? Window : -1);
  1848.  
  1849.             break;
  1850.         }
  1851.     }
  1852. }
  1853.  
  1854. VOID
  1855. RexxSetSerial(UBYTE *String)
  1856. {
  1857.     if(!Stricmp(String,Booleans[0]) && ReadPort)
  1858.         DeleteSerial();
  1859.  
  1860.     if(!Stricmp(String,Booleans[1]) && !ReadPort)
  1861.     {
  1862.         if(CreateSerial())
  1863.             RexxRes1 = RC_ERROR;
  1864.         else
  1865.             SerialMessage = NULL;
  1866.     }
  1867. }
  1868.  
  1869. VOID
  1870. RexxSetTimeout(UBYTE *String)
  1871. {
  1872.     UBYTE    Arg1[40],Arg2[40];
  1873.     LONG    ArgCount;
  1874.  
  1875.     ULONG    Time = 0;
  1876.     WORD    i;
  1877.  
  1878.     Arg1[0] = Arg2[0] = 0;
  1879.     ArgCount = 0;
  1880.  
  1881.     GetToken(String,&ArgCount,Arg1,40);
  1882.     GetToken(String,&ArgCount,Arg2,40);
  1883.  
  1884.     for(i = 0 ; i < NUMTIMEREL ; i++)
  1885.     {
  1886.         if(!Stricmp(Arg2,TimeRelations[i] . Key))
  1887.         {
  1888.             Time = atol(String) * TimeRelations[i] . Multi;
  1889.             break;
  1890.         }
  1891.     }
  1892.  
  1893.     if(Time > 0)
  1894.         RexxGlobalTimeout = Time;
  1895.     else
  1896.         RexxRes1 = RC_ERROR;
  1897. }
  1898.  
  1899. VOID
  1900. RexxSetModemHangup(UBYTE *String)
  1901. {
  1902.     strcpy(Config . ModemHangup,String);
  1903. }
  1904.  
  1905. VOID
  1906. RexxSetAutoCapture(UBYTE *String)
  1907. {
  1908.     WORD i;
  1909.  
  1910.     for(i = 0 ; i < 2 ; i++)
  1911.     {
  1912.         if(!Stricmp(String,Booleans[i]))
  1913.         {
  1914.             Config . ConnectAutoCapture = i;
  1915.             break;
  1916.         }
  1917.     }
  1918. }
  1919.  
  1920. VOID
  1921. RexxSetLogActions(UBYTE *String)
  1922. {
  1923.     WORD i;
  1924.  
  1925.     for(i = 0 ; i < 2 ; i++)
  1926.     {
  1927.         if(!Stricmp(String,Booleans[i]))
  1928.         {
  1929.             Config . LogActions = i;
  1930.             break;
  1931.         }
  1932.     }
  1933. }
  1934.  
  1935. VOID
  1936. RexxSetBlinking(UBYTE *String)
  1937. {
  1938.     WORD i;
  1939.  
  1940.     for(i = 0 ; i < 2 ; i++)
  1941.     {
  1942.         if(!Stricmp(String,Booleans[i]))
  1943.         {
  1944.             Config . DisableBlinking = TRUE ^ i;
  1945.             break;
  1946.         }
  1947.     }
  1948. }
  1949.  
  1950. VOID
  1951. RexxSetCursorMode(UBYTE *String)
  1952. {
  1953.     WORD i;
  1954.  
  1955.     for(i = 0 ; i < 2 ; i++)
  1956.     {
  1957.         if(!Stricmp(String,KeyModes[i]))
  1958.         {
  1959.             Config . CursorApp = i;
  1960.             break;
  1961.         }
  1962.     }
  1963. }
  1964.  
  1965. VOID
  1966. RexxSetFontScale(UBYTE *String)
  1967. {
  1968.     WORD i;
  1969.  
  1970.     for(i = 0 ; i < 5 ; i++)
  1971.     {
  1972.         if(!Stricmp(String,FontSizes[i]))
  1973.         {
  1974.             if(i != SCALE_HALF && Config . FontScale == SCALE_HALF)
  1975.             {
  1976.                 CursorX >>= 1;
  1977.                 SetCursor();
  1978.  
  1979.                 if(Config . EightyColumns)
  1980.                     LastColumn = 79;
  1981.                 else
  1982.                     LastColumn = (Window -> Width >> 3) - 1;
  1983.             }
  1984.  
  1985.             if(i == SCALE_HALF && Config . FontScale != SCALE_HALF)
  1986.             {
  1987.                 if(Config . EightyColumns)
  1988.                     LastColumn = 131;
  1989.                 else
  1990.                     LastColumn = (Window -> Width >> 2) - 1;
  1991.             }
  1992.  
  1993.             Config . FontScale = i;
  1994.             break;
  1995.         }
  1996.     }
  1997. }
  1998.  
  1999. VOID
  2000. RexxSetJumpScroll(UBYTE *String)
  2001. {
  2002.     WORD i;
  2003.  
  2004.     for(i = 0 ; i < 2 ; i++)
  2005.     {
  2006.         if(!Stricmp(String,Booleans[i]))
  2007.         {
  2008.             Config . JumpScroll = TRUE ^ i;
  2009.             break;
  2010.         }
  2011.     }
  2012. }
  2013.  
  2014. VOID
  2015. RexxSetCharacterWrap(UBYTE *String)
  2016. {
  2017.     WORD i;
  2018.  
  2019.     for(i = 0 ; i < 2 ; i++)
  2020.     {
  2021.         if(!Stricmp(String,Booleans[i]))
  2022.         {
  2023.             Config . AutoWrap = i;
  2024.             break;
  2025.         }
  2026.     }
  2027. }
  2028.  
  2029. VOID
  2030. RexxSetCursorWrap(UBYTE *String)
  2031. {
  2032.     WORD i;
  2033.  
  2034.     for(i = 0 ; i < 2 ; i++)
  2035.     {
  2036.         if(!Stricmp(String,Booleans[i]))
  2037.         {
  2038.             Config . CursorWrap = i;
  2039.             break;
  2040.         }
  2041.     }
  2042. }
  2043.  
  2044. VOID
  2045. RexxSetNewLine(UBYTE *String)
  2046. {
  2047.     WORD i;
  2048.  
  2049.     for(i = 0 ; i < 2 ; i++)
  2050.     {
  2051.         if(!Stricmp(String,Booleans[i]))
  2052.         {
  2053.             Config . NewLine = i;
  2054.             break;
  2055.         }
  2056.     }
  2057. }
  2058.  
  2059. VOID
  2060. RexxSetInsert(UBYTE *String)
  2061. {
  2062.     WORD i;
  2063.  
  2064.     for(i = 0 ; i < 2 ; i++)
  2065.     {
  2066.         if(!Stricmp(String,Booleans[i]))
  2067.         {
  2068.             Config . InsertChar = i;
  2069.             break;
  2070.         }
  2071.     }
  2072. }
  2073.  
  2074. VOID
  2075. RexxSetNumeric(UBYTE *String)
  2076. {
  2077.     WORD i;
  2078.  
  2079.     for(i = 0 ; i < 2 ; i++)
  2080.     {
  2081.         if(!Stricmp(String,KeyModes[i]))
  2082.         {
  2083.             Config . NumApp = i;
  2084.             break;
  2085.         }
  2086.     }
  2087. }
  2088.  
  2089. VOID
  2090. RexxSetDefaultStore(UBYTE *String)
  2091. {
  2092.     strcpy(Config . DefaultStorage,String);
  2093. }
  2094.  
  2095. VOID
  2096. RexxSetTUploadPath(UBYTE *String)
  2097. {
  2098.     strcpy(Config . TextUploadPath,String);
  2099. }
  2100.  
  2101. VOID
  2102. RexxSetTDownloadPath(UBYTE *String)
  2103. {
  2104.     strcpy(Config . TextDownloadPath,String);
  2105. }
  2106.  
  2107. VOID
  2108. RexxSetAUploadPath(UBYTE *String)
  2109. {
  2110.     strcpy(Config . ASCIIUploadPath,String);
  2111. }
  2112.  
  2113. VOID
  2114. RexxSetADownloadPath(UBYTE *String)
  2115. {
  2116.     strcpy(Config . ASCIIDownloadPath,String);
  2117. }
  2118.  
  2119. VOID
  2120. RexxSetBUploadPath(UBYTE *String)
  2121. {
  2122.     strcpy(Config . BinaryUploadPath,String);
  2123. }
  2124.  
  2125. VOID
  2126. RexxSetBDownloadPath(UBYTE *String)
  2127. {
  2128.     strcpy(Config . BinaryDownloadPath,String);
  2129. }
  2130.  
  2131. VOID
  2132. RexxSetCapturePath(UBYTE *String)
  2133. {
  2134.     strcpy(Config . CapturePath,String);
  2135. }
  2136.  
  2137. VOID
  2138. RexxSetLogFile(UBYTE *String)
  2139. {
  2140.     strcpy(Config . LogFile,String);
  2141. }
  2142.  
  2143. VOID
  2144. RexxSetEditor(UBYTE *String)
  2145. {
  2146.     strcpy(Config . Editor,String);
  2147. }
  2148.  
  2149. VOID
  2150. RexxSetSpeechRate(UBYTE *String)
  2151. {
  2152.     SpeechConfig . Rate = atol(String);
  2153.  
  2154.     SpeechSetup();
  2155. }
  2156.  
  2157. VOID
  2158. RexxSetSpeechPitch(UBYTE *String)
  2159. {
  2160.     SpeechConfig . Pitch = atol(String);
  2161.  
  2162.     SpeechSetup();
  2163. }
  2164.  
  2165. VOID
  2166. RexxSetSpeechFrequency(UBYTE *String)
  2167. {
  2168.     SpeechConfig . Frequency = atol(String);
  2169.  
  2170.     SpeechSetup();
  2171. }
  2172.  
  2173. VOID
  2174. RexxSetSpeechVolume(UBYTE *String)
  2175. {
  2176.     SpeechConfig . Volume = atol(String);
  2177.  
  2178.     SpeechSetup();
  2179. }
  2180.  
  2181. VOID
  2182. RexxSetSpeechSex(UBYTE *String)
  2183. {
  2184.     if(!Stricmp(String,"MALE"))
  2185.     {
  2186.         SpeechConfig . Sex = 0;
  2187.  
  2188.         SpeechSetup();
  2189.     }
  2190.     else
  2191.     {
  2192.         if(!Stricmp(String,"FEMALE"))
  2193.         {
  2194.             SpeechConfig . Sex = 1;
  2195.  
  2196.             SpeechSetup();
  2197.         }
  2198.         else
  2199.             RexxRes1 = RC_ERROR;
  2200.     }
  2201. }
  2202.  
  2203. VOID
  2204. RexxSetSpeech(UBYTE *String)
  2205. {
  2206.     WORD i;
  2207.  
  2208.     for(i = 0 ; i < 2 ; i++)
  2209.     {
  2210.         if(!Stricmp(String,Booleans[i]))
  2211.         {
  2212.             SpeechConfig . Enabled = i;
  2213.  
  2214.             SpeechSetup();
  2215.  
  2216.             break;
  2217.         }
  2218.     }
  2219. }
  2220.  
  2221. UBYTE *
  2222. RexxBreak()
  2223. {
  2224.     BYTE OldStatus = Status;
  2225.  
  2226.     if(WriteRequest)
  2227.     {
  2228.         Status = STATUS_BREAKING;
  2229.  
  2230.         WriteRequest -> IOSer . io_Command = SDCMD_BREAK;
  2231.  
  2232.         DoIO(WriteRequest);
  2233.  
  2234.         Status = OldStatus;
  2235.     }
  2236.  
  2237.     return(NULL);
  2238. }
  2239.  
  2240. UBYTE *
  2241. RexxTUpload(UBYTE *String)
  2242. {
  2243.     BinaryTransfer = FALSE;
  2244.  
  2245.     RexxBUpload(String);
  2246.  
  2247.     return(NULL);
  2248. }
  2249.  
  2250. UBYTE *
  2251. RexxTDownload(UBYTE *String)
  2252. {
  2253.     BinaryTransfer = FALSE;
  2254.  
  2255.     RexxBDownload(String);
  2256.  
  2257.     return(NULL);
  2258. }
  2259.  
  2260. UBYTE *
  2261. RexxBDownload(UBYTE *String)
  2262. {
  2263.     BYTE OldStatus = Status;
  2264.  
  2265.     if(XProtocolBase)
  2266.     {
  2267.         if(!(TransferBits & XPRS_NORECREQ))
  2268.         {
  2269.             XprIO -> xpr_filename = String;
  2270.  
  2271.             DownloadPath = "";
  2272.         }
  2273.         else
  2274.         {
  2275.             if(BinaryTransfer)
  2276.                 DownloadPath = &Config . BinaryDownloadPath[0];
  2277.             else
  2278.                 DownloadPath = &Config . TextDownloadPath[0];
  2279.         }
  2280.  
  2281.         if(TransferPanel(BinaryTransfer ? "Download File(s)" : "Download Text"))
  2282.         {
  2283.             Status = STATUS_DOWNLOAD;
  2284.  
  2285.             ClearSerial();
  2286.  
  2287.             Uploading = FALSE;
  2288.  
  2289.             XProtocolReceive(XprIO);
  2290.  
  2291.             Status = OldStatus;
  2292.  
  2293.             if(ReadRequest)
  2294.             {
  2295.                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  2296.                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2297.                 ReadRequest -> IOSer . io_Length    = 1;
  2298.  
  2299.                 SetSignal(0,SIG_SERIAL);
  2300.  
  2301.                 SendIO(ReadRequest);
  2302.             }
  2303.  
  2304.             DeleteTransferPanel();
  2305.  
  2306.             if(Config . DownloadMacro[0])
  2307.                 SerialCommand(Config . DownloadMacro);
  2308.         }
  2309.  
  2310.         DownloadPath = NULL;
  2311.     }
  2312.  
  2313.     BinaryTransfer = TRUE;
  2314.  
  2315.     return(NULL);
  2316. }
  2317.  
  2318. UBYTE *
  2319. RexxBUpload(UBYTE *String)
  2320. {
  2321.     BYTE OldStatus = Status;
  2322.  
  2323.     if(XProtocolBase)
  2324.     {
  2325.         if(!(TransferBits & XPRS_NOSNDREQ))
  2326.             XprIO -> xpr_filename = String;
  2327.  
  2328.         if(TransferPanel(BinaryTransfer ? "Upload File(s)" : "Upload Text"))
  2329.         {
  2330.             Status = STATUS_UPLOAD;
  2331.  
  2332.             ClearSerial();
  2333.  
  2334.             Uploading = TRUE;
  2335.  
  2336.             XProtocolSend(XprIO);
  2337.  
  2338.             Uploading = FALSE;
  2339.  
  2340.             Status = OldStatus;
  2341.  
  2342.             DeleteTransferPanel();
  2343.  
  2344.             if(ReadRequest)
  2345.             {
  2346.                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  2347.                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2348.                 ReadRequest -> IOSer . io_Length    = 1;
  2349.  
  2350.                 SetSignal(0,SIG_SERIAL);
  2351.  
  2352.                 SendIO(ReadRequest);
  2353.             }
  2354.  
  2355.             if(Config . UploadMacro[0])
  2356.                 SerialCommand(Config . UploadMacro);
  2357.         }
  2358.     }
  2359.  
  2360.     BinaryTransfer = TRUE;
  2361.  
  2362.     return(NULL);
  2363. }
  2364.  
  2365. UBYTE *
  2366. RexxWrite(UBYTE *String,UBYTE *String2)
  2367. {
  2368.     if(String2[0])
  2369.         SerWrite(String2,strlen(String2));
  2370.     else
  2371.         RexxRes1 = RC_ERROR;
  2372.  
  2373.     return(NULL);
  2374. }
  2375.  
  2376. UBYTE *
  2377. RexxResetStyles()
  2378. {
  2379.     Escape = TRUE;
  2380.  
  2381.     ConProcess("\033[m",3);
  2382.  
  2383.     switch(Config . ColourMode)
  2384.     {
  2385.         case COLOUR_EIGHT:    FgPen = 7;
  2386.                     break;
  2387.  
  2388.         case COLOUR_SIXTEEN:    FgPen = 15;
  2389.                     break;
  2390.  
  2391.         case COLOUR_AMIGA:
  2392.         default:        FgPen = 1;
  2393.                     break;
  2394.     }
  2395.  
  2396.     BgPen = 0;
  2397.  
  2398.     if(RPort -> FgPen != FgPen)
  2399.         SetAPen(RPort,FgPen);
  2400.  
  2401.     if(RPort -> BgPen != BgPen)
  2402.         SetBPen(RPort,BgPen);
  2403.  
  2404.     SetWrMsk(RPort,0xFF);
  2405.  
  2406.     Config . FontScale = SCALE_NORMAL;
  2407.  
  2408.     Escape = FALSE;
  2409.  
  2410.     return(NULL);
  2411. }
  2412.  
  2413. UBYTE *
  2414. RexxClearScreen()
  2415. {
  2416.     Escape = TRUE;
  2417.  
  2418.     ConProcess("\033[2J\033[H",7);
  2419.  
  2420.     Escape = FALSE;
  2421.  
  2422.     return(NULL);
  2423. }
  2424.  
  2425. UBYTE *
  2426. RexxSaveILBM(UBYTE *String)
  2427. {
  2428.     if(!SaveRPort(&Screen -> RastPort,VPort,0,Window -> TopEdge,Window -> Width,Window -> Height,Screen -> Width,Screen -> Height,FALSE,String))
  2429.         RexxRes1 = RC_ERROR;
  2430.  
  2431.     return(NULL);
  2432. }
  2433.  
  2434. UBYTE *
  2435. RexxHangUp()
  2436. {
  2437.     BYTE OldStatus = Status;
  2438.  
  2439.     Status = STATUS_HANGUP;
  2440.  
  2441.         /* Are we to drop the DTR line
  2442.          * before sending the hangup
  2443.          * string?
  2444.          */
  2445.  
  2446.     if(Config . DropDTR)
  2447.     {
  2448.         /* Let's be nice and try to transmit the
  2449.          * `drop the line' command before
  2450.          * trying to close and reopen the driver.
  2451.          */
  2452.  
  2453.         WriteRequest -> IOSer . io_Command    = SIOCMD_SETCTRLLINES;
  2454.         WriteRequest -> IOSer . io_Offset    = SIOB_DTRF;
  2455.         WriteRequest -> IOSer . io_Length    = 0;
  2456.  
  2457.         /* Transmit the command. */
  2458.  
  2459.         if(!DoIO(WriteRequest))
  2460.         {
  2461.             /* Wait a bit... */
  2462.  
  2463.             WaitTime(1,0);
  2464.  
  2465.             /* Raise the line again. */
  2466.  
  2467.             WriteRequest -> IOSer . io_Command    = SIOCMD_SETCTRLLINES;
  2468.             WriteRequest -> IOSer . io_Offset    = SIOB_DTRF;
  2469.             WriteRequest -> IOSer . io_Length    = SIOB_DTRF;
  2470.  
  2471.             DoIO(WriteRequest);
  2472.         }
  2473.         else
  2474.         {
  2475.             /* Do it the standard way: close and reopen
  2476.              * the serial driver (the serial.device is
  2477.              * supposed to drop the DTR line when closed).
  2478.              */
  2479.  
  2480.             DropDTR();
  2481.         }
  2482.     }
  2483.  
  2484.         /* Transmit the hangup command. */
  2485.  
  2486.     SerialCommand(Config . ModemHangup);
  2487.  
  2488.         /* Reset to old status. */
  2489.  
  2490.     Status = OldStatus;
  2491.  
  2492.         /* We are no longer online. */
  2493.  
  2494.     Online = FALSE;
  2495.  
  2496.         /* Clear the password. */
  2497.  
  2498.     Password[0] = 0;
  2499.  
  2500.         /* Clear the user name as well. */
  2501.  
  2502.     UserName[0] = 0;
  2503.  
  2504.         /* Note the  last action. */
  2505.  
  2506.     LogAction("Hung up the line.");
  2507.  
  2508.     return(NULL);
  2509. }
  2510.  
  2511. UBYTE *
  2512. RexxGetString(UBYTE *String)
  2513. {
  2514.     RexxTextBuffer[0] = 0;
  2515.  
  2516.     if(xpr_gets(String[0] ? String : "Get String For Rexx",RexxTextBuffer))
  2517.         return(RexxTextBuffer);
  2518.     else
  2519.         return(NULL);
  2520. }
  2521.  
  2522. UBYTE *
  2523. RexxCommand(UBYTE *String,UBYTE *String2)
  2524. {
  2525.     if(String2[0])
  2526.         SerialCommand(String2);
  2527.     else
  2528.         RexxRes1 = RC_ERROR;
  2529.  
  2530.     return(NULL);
  2531. }
  2532.  
  2533. UBYTE *
  2534. RexxMessage(UBYTE *String,UBYTE *String2)
  2535. {
  2536.     if(String2[0])
  2537.         ConProcess(String2,strlen(String2));
  2538.     else
  2539.         RexxRes1 = RC_ERROR;
  2540.  
  2541.     return(NULL);
  2542. }
  2543.  
  2544. UBYTE *
  2545. RexxPutClip(UBYTE *String,UBYTE *String2)
  2546. {
  2547.     if(String2[0])
  2548.         SaveClip(String2,strlen(String2));
  2549.     else
  2550.         RexxRes1 = RC_ERROR;
  2551.  
  2552.     return(NULL);
  2553. }
  2554.  
  2555. UBYTE *
  2556. RexxGetClip()
  2557. {
  2558.     LONG Size;
  2559.  
  2560.     if(Size = LoadClip(RexxTextBuffer,255))
  2561.     {
  2562.         RexxTextBuffer[Size] = 0;
  2563.  
  2564.         return(RexxTextBuffer);
  2565.     }
  2566.     else
  2567.         return(NULL);
  2568. }
  2569.  
  2570. UBYTE *
  2571. RexxDelay(UBYTE *String)
  2572. {
  2573.     UBYTE    Arg1[40],Arg2[40];
  2574.     LONG    ArgCount;
  2575.  
  2576.     ULONG    Time = 0;
  2577.     WORD    i;
  2578.  
  2579.     Arg1[0] = Arg2[0] = 0;
  2580.  
  2581.     ArgCount = 0;
  2582.  
  2583.     GetToken(String,&ArgCount,Arg1,40);
  2584.     GetToken(String,&ArgCount,Arg2,40);
  2585.  
  2586.     for(i = 0 ; i < NUMTIMEREL ; i++)
  2587.     {
  2588.         if(!Stricmp(Arg2,TimeRelations[i] . Key))
  2589.         {
  2590.             Time = atol(String) * TimeRelations[i] . Multi;
  2591.             break;
  2592.         }
  2593.     }
  2594.  
  2595.     if(Time)
  2596.     {
  2597.         ULONG SignalSet;
  2598.  
  2599.         TimeRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  2600.         TimeRequest -> tr_time . tv_secs    = Time / MILLION;
  2601.         TimeRequest -> tr_time . tv_micro    = Time % MILLION;
  2602.  
  2603.         SendIO(TimeRequest);
  2604.  
  2605.         SignalSet = Wait(SIGBREAKF_CTRL_D | SIG_TIMER);
  2606.  
  2607.         if(SignalSet & SIGBREAKF_CTRL_D)
  2608.         {
  2609.             if(!CheckIO(TimeRequest))
  2610.                 AbortIO(TimeRequest);
  2611.  
  2612.             WaitIO(TimeRequest);
  2613.  
  2614.             return(NULL);
  2615.         }
  2616.  
  2617.         WaitIO(TimeRequest);
  2618.     }
  2619.     else
  2620.         RexxRes1 = RC_ERROR;
  2621.  
  2622.     return(NULL);
  2623. }
  2624.  
  2625. UBYTE *
  2626. RexxDial(UBYTE *String)
  2627. {
  2628.     LONG i;
  2629.  
  2630.     strcpy(RexxTextBuffer,Config . DialPrefix);
  2631.  
  2632.     for(i = 0 ; i < NumPhoneEntries ; i++)
  2633.     {
  2634.         if(!Stricmp(Phonebook[i] -> Name,String))
  2635.         {
  2636.             strcat(RexxTextBuffer,Phonebook[i] -> Number);
  2637.  
  2638.             goto DialIt;
  2639.         }
  2640.     }
  2641.  
  2642.     strcat(RexxTextBuffer,String);
  2643.  
  2644. DialIt:    strcat(RexxTextBuffer,"\\r");
  2645.  
  2646.     SerialCommand(RexxTextBuffer);
  2647.  
  2648.     return(NULL);
  2649. }
  2650.  
  2651. UBYTE *
  2652. RexxInput(UBYTE *String)
  2653. {
  2654.     LONG Length = atol(String);
  2655.  
  2656.     if(Length > 255)
  2657.         Length = 255;
  2658.  
  2659.     ClearSerial();
  2660.  
  2661.     if(Length = xpr_sread(RexxTextBuffer,Length,RexxGlobalTimeout))
  2662.     {
  2663.         RexxTextBuffer[Length] = 0;
  2664.  
  2665.         if(ReadRequest)
  2666.         {
  2667.             ReadRequest -> IOSer . io_Command    = CMD_READ;
  2668.             ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2669.             ReadRequest -> IOSer . io_Length    = 1;
  2670.  
  2671.             SetSignal(0,SIG_SERIAL);
  2672.  
  2673.             SendIO(ReadRequest);
  2674.         }
  2675.  
  2676.         return(RexxTextBuffer);
  2677.     }
  2678.  
  2679.     if(ReadRequest)
  2680.     {
  2681.         ReadRequest -> IOSer . io_Command    = CMD_READ;
  2682.         ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2683.         ReadRequest -> IOSer . io_Length    = 1;
  2684.  
  2685.         SetSignal(0,SIG_SERIAL);
  2686.  
  2687.         SendIO(ReadRequest);
  2688.     }
  2689.  
  2690.     return(NULL);
  2691. }
  2692.  
  2693. UBYTE *
  2694. RexxPrinter(UBYTE *String)
  2695. {
  2696.     struct MenuItem *SomeItem;
  2697.  
  2698.     SomeItem = FindThisItem(MEN_CAPTUREPRINTER);
  2699.  
  2700.     if(!Stricmp(String,Booleans[0]) && PrinterCapture)
  2701.         ClosePrinterCapture(TRUE);
  2702.  
  2703.     if(!Stricmp(String,Booleans[1]) && !PrinterCapture)
  2704.     {
  2705.         if(!OpenPrinterCapture(FALSE))
  2706.             RexxRes1 = RC_ERROR;
  2707.     }
  2708.  
  2709.     return(NULL);
  2710. }
  2711.  
  2712. UBYTE *
  2713. RexxMacros(UBYTE *String)
  2714. {
  2715.     UBYTE Arg1[40],Arg2[256];
  2716.     LONG ArgCount;
  2717.  
  2718.     Arg1[0] = Arg2[0] = 0;
  2719.     ArgCount = 0;
  2720.  
  2721.     GetToken(String,&ArgCount,Arg1,40);
  2722.     GetToken(String,&ArgCount,Arg2,256);
  2723.  
  2724.     if(!Stricmp(Arg1,"SAVE"))
  2725.     {
  2726.         if(Arg2[0])
  2727.         {
  2728.             if(WriteIFFData(Arg2,MacroKeys,sizeof(struct MacroKeys),'KEYS'))
  2729.                 strcpy(LastMacros,Arg2);
  2730.             else
  2731.                 RexxRes1 = RC_ERROR;
  2732.         }
  2733.     }
  2734.  
  2735.     if(!Stricmp(Arg1,"LOAD"))
  2736.     {
  2737.         if(Arg2[0])
  2738.         {
  2739.             if(LoadMacros(Arg2,MacroKeys))
  2740.                 strcpy(LastMacros,Arg2);
  2741.             else
  2742.                 RexxRes1 = RC_ERROR;
  2743.         }
  2744.     }
  2745.  
  2746.     return(NULL);
  2747. }
  2748.  
  2749. UBYTE *
  2750. RexxSpeech(UBYTE *String)
  2751. {
  2752.     UBYTE Arg1[40],Arg2[256];
  2753.     LONG ArgCount;
  2754.  
  2755.     Arg1[0] = Arg2[0] = 0;
  2756.     ArgCount = 0;
  2757.  
  2758.     GetToken(String,&ArgCount,Arg1,40);
  2759.     GetToken(String,&ArgCount,Arg2,256);
  2760.  
  2761.     if(!Stricmp(Arg1,"SAVE"))
  2762.     {
  2763.         if(Arg2[0])
  2764.         {
  2765.             if(!WriteIFFData(Arg2,&SpeechConfig,sizeof(struct SpeechConfig),'SPEK'))
  2766.                 RexxRes1 = RC_ERROR;
  2767.             else
  2768.                 strcpy(LastSpeech,Arg2);
  2769.         }
  2770.     }
  2771.  
  2772.     if(!Stricmp(Arg1,"LOAD"))
  2773.     {
  2774.         if(Arg2[0])
  2775.         {
  2776.             if(!ReadIFFData(Arg2,&SpeechConfig,sizeof(struct SpeechConfig),'SPEK'))
  2777.                 RexxRes1 = RC_ERROR;
  2778.             else
  2779.             {
  2780.                 strcpy(LastSpeech,Arg2);
  2781.  
  2782.                 SpeechSetup();
  2783.             }
  2784.         }
  2785.     }
  2786.  
  2787.     return(NULL);
  2788. }
  2789.  
  2790. UBYTE *
  2791. RexxConfig(UBYTE *String)
  2792. {
  2793.     UBYTE Arg1[40],Arg2[256];
  2794.     LONG ArgCount;
  2795.  
  2796.     Arg1[0] = Arg2[0] = 0;
  2797.     ArgCount = 0;
  2798.  
  2799.     GetToken(String,&ArgCount,Arg1,40);
  2800.     GetToken(String,&ArgCount,Arg2,256);
  2801.  
  2802.     if(!Stricmp(Arg1,"SAVE"))
  2803.     {
  2804.         if(Arg2[0])
  2805.         {
  2806.             if(WriteIFFData(Arg2,&Config,sizeof(struct Configuration),'PREF'))
  2807.                 strcpy(LastConfig,Arg2);
  2808.             else
  2809.                 RexxRes1 = RC_ERROR;
  2810.         }
  2811.     }
  2812.  
  2813.     if(!Stricmp(Arg1,"LOAD"))
  2814.     {
  2815.         if(Arg2[0])
  2816.         {
  2817.             struct Configuration PrivateConfig;
  2818.  
  2819.             if(ReadIFFData(Arg2,&PrivateConfig,sizeof(struct Configuration),'PREF'))
  2820.             {
  2821.                 Config = PrivateConfig;
  2822.  
  2823.                 ConfigSetup();
  2824.  
  2825.                 strcpy(LastConfig,Arg2);
  2826.             }
  2827.             else
  2828.                 RexxRes1 = RC_ERROR;
  2829.         }
  2830.     }
  2831.  
  2832.     return(NULL);
  2833. }
  2834.  
  2835. UBYTE *
  2836. RexxPhone(UBYTE *String)
  2837. {
  2838.     UBYTE Arg1[40],Arg2[256];
  2839.     LONG ArgCount;
  2840.  
  2841.     Arg1[0] = Arg2[0] = 0;
  2842.     ArgCount = 0;
  2843.  
  2844.     GetToken(String,&ArgCount,Arg1,40);
  2845.     GetToken(String,&ArgCount,Arg2,256);
  2846.  
  2847.     if(!Stricmp(Arg1,"SAVE"))
  2848.     {
  2849.         if(Arg2[0])
  2850.         {
  2851.             if(SavePhonebook(Arg2))
  2852.                 strcpy(LastPhone,Arg2);
  2853.             else
  2854.                 RexxRes1 = RC_ERROR;
  2855.         }
  2856.     }
  2857.  
  2858.     if(!Stricmp(Arg1,"LOAD"))
  2859.     {
  2860.         if(Arg2[0])
  2861.         {
  2862.             if(LoadPhonebook(Arg2))
  2863.                 strcpy(LastPhone,Arg2);
  2864.             else
  2865.                 RexxRes1 = RC_ERROR;
  2866.         }
  2867.     }
  2868.  
  2869.     return(NULL);
  2870. }
  2871.  
  2872. UBYTE *
  2873. RexxCapture(UBYTE *String)
  2874. {
  2875.     UBYTE Arg1[40],Arg2[256];
  2876.     LONG ArgCount;
  2877.  
  2878.     Arg1[0] = Arg2[0] = 0;
  2879.     ArgCount = 0;
  2880.  
  2881.     GetToken(String,&ArgCount,Arg1,40);
  2882.     GetToken(String,&ArgCount,Arg2,256);
  2883.  
  2884.     if(!Stricmp(Arg1,"CLOSE") && FileCapture)
  2885.     {
  2886.         struct MenuItem *SomeItem;
  2887.  
  2888.         SomeItem = FindThisItem(MEN_CAPTUREDISK);
  2889.  
  2890.         BufferClose(FileCapture);
  2891.  
  2892.         SomeItem -> Flags &= ~CHECKED;
  2893.  
  2894.         FileCapture = NULL;
  2895.  
  2896.         if(!GetFileSize(CaptureName))
  2897.             DeleteFile(CaptureName);
  2898.         else
  2899.             SetProtection(CaptureName,FIBF_EXECUTE);
  2900.     }
  2901.     else
  2902.     {
  2903.         if(!Stricmp(Arg1,"NEW") && Arg2[0])
  2904.             FileCapture = BufferOpen(Arg2,"w");
  2905.         else
  2906.         {
  2907.             if(!Stricmp(Arg1,"APPEND") && Arg2[0])
  2908.                 FileCapture = BufferOpen(Arg2,"a");
  2909.         }
  2910.  
  2911.         if(FileCapture)
  2912.         {
  2913.             struct MenuItem *SomeItem;
  2914.  
  2915.             strcpy(CaptureName,Arg2);
  2916.  
  2917.             SomeItem = FindThisItem(MEN_CAPTUREDISK);
  2918.  
  2919.             SomeItem -> Flags |= CHECKED;
  2920.         }
  2921.         else
  2922.             RexxRes1 = RC_ERROR;
  2923.     }
  2924.  
  2925.     return(NULL);
  2926. }
  2927.  
  2928. UBYTE *
  2929. RexxBuffer(UBYTE *String)
  2930. {
  2931.     UBYTE Arg1[40],Arg2[256];
  2932.     LONG ArgCount;
  2933.  
  2934.     Arg1[0] = Arg2[0] = 0;
  2935.     ArgCount = 0;
  2936.  
  2937.     GetToken(String,&ArgCount,Arg1,40);
  2938.     GetToken(String,&ArgCount,Arg2,256);
  2939.  
  2940.     if(!Stricmp(Arg1,"NEW") || !Stricmp(Arg1,"APPEND"))
  2941.     {
  2942.         if(GetFileSize(Arg2))
  2943.         {
  2944.             BPTR SomeFile;
  2945.  
  2946.             if(SomeFile = Open(Arg2,MODE_OLDFILE))
  2947.             {
  2948.                 LONG Len;
  2949.  
  2950.                 if(Lines)
  2951.                 {
  2952.                     if(!Stricmp(Arg1,"NEW"))
  2953.                         ClearBuffer();
  2954.                 }
  2955.  
  2956.                 LineRead(NULL,NULL,NULL);
  2957.  
  2958.                 while(Len = LineRead(SomeFile,Arg2,80))
  2959.                     StoreBuffer(Arg2,Len);
  2960.  
  2961.                 Close(SomeFile);
  2962.             }
  2963.             else
  2964.                 RexxRes1 = RC_ERROR;
  2965.         }
  2966.         else
  2967.             RexxRes1 = RC_ERROR;
  2968.     }
  2969.     else
  2970.     {
  2971.         if(!Stricmp(Arg1,"DISPLAY"))
  2972.         {
  2973.             if(BufferProcess)
  2974.                 Signal(BufferProcess,SIGBREAKF_CTRL_D);
  2975.             else
  2976.             {
  2977.                 if(BufferProcess = (struct Process *)CreateNewProcTags(
  2978.                     NP_Entry,    BufferServer,
  2979.                     NP_Name,    "term Buffer Process",
  2980.                     NP_Priority,    0,
  2981.                     NP_StackSize,    8192,
  2982.                     NP_WindowPtr,    -1,
  2983.                 TAG_END))
  2984.                     Wait(SIGBREAKF_CTRL_C);
  2985.             }
  2986.         }
  2987.     }
  2988.  
  2989.     return(NULL);
  2990. }
  2991.  
  2992. UBYTE *
  2993. RexxFirstDownload()
  2994. {
  2995.     ObtainSemaphore(DownloadSemaphore);
  2996.  
  2997.     if(DownloadLineCount)
  2998.     {
  2999.         DownloadNode = DownloadList . lh_Head;
  3000.  
  3001.         if(DownloadNode -> ln_Succ)
  3002.         {
  3003.             strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  3004.  
  3005.             ReleaseSemaphore(DownloadSemaphore);
  3006.  
  3007.             return(RexxTextBuffer);
  3008.         }
  3009.     }
  3010.  
  3011.     ReleaseSemaphore(DownloadSemaphore);
  3012.  
  3013.     return("");
  3014. }
  3015.  
  3016. UBYTE *
  3017. RexxNextDownload()
  3018. {
  3019.     ObtainSemaphore(DownloadSemaphore);
  3020.  
  3021.     if(!DownloadNode)
  3022.         DownloadNode = DownloadList . lh_Head;
  3023.     else
  3024.         DownloadNode = DownloadNode -> ln_Succ;
  3025.  
  3026.     if(DownloadNode -> ln_Succ)
  3027.     {
  3028.         strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  3029.  
  3030.         ReleaseSemaphore(DownloadSemaphore);
  3031.  
  3032.         return(RexxTextBuffer);
  3033.     }
  3034.     else
  3035.         DownloadNode = NULL;
  3036.  
  3037.     ReleaseSemaphore(DownloadSemaphore);
  3038.  
  3039.     return("");
  3040. }
  3041.  
  3042. UBYTE *
  3043. RexxLastDownload()
  3044. {
  3045.     ObtainSemaphore(DownloadSemaphore);
  3046.  
  3047.     if(DownloadLineCount)
  3048.     {
  3049.         DownloadNode = DownloadList . lh_TailPred;
  3050.  
  3051.         strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  3052.  
  3053.         ReleaseSemaphore(DownloadSemaphore);
  3054.  
  3055.         return(RexxTextBuffer);
  3056.     }
  3057.  
  3058.     ReleaseSemaphore(DownloadSemaphore);
  3059.  
  3060.     return("");
  3061. }
  3062.  
  3063. UBYTE *
  3064. RexxWaitString(UBYTE *String)
  3065. {
  3066.     UBYTE         Arg1[40];
  3067.     LONG         ArgCount;
  3068.  
  3069.     struct ScanNode    *Matching = NULL;
  3070.  
  3071.     ULONG         SignalSet;
  3072.     WORD         i;
  3073.  
  3074.     ULONG         Timeout = RexxGlobalTimeout;
  3075.  
  3076.     if(ReadPort)
  3077.     {
  3078.         Arg1[0] = 0;
  3079.  
  3080.         ArgCount = 0;
  3081.  
  3082.             /* Parse the argument looking for sequences
  3083.              * to wait for.
  3084.              */
  3085.  
  3086.         while(GetToken(String,&ArgCount,Arg1,40))
  3087.             AddSequenceObject(Arg1);
  3088.  
  3089.             /* If no timeout is set this routine becomes
  3090.              * a real trap: suppose the string to wait for
  3091.              * never happens to arrive -> we'll wait
  3092.              * forever. For this reason the default timeout
  3093.              * is set to five seconds.
  3094.              */
  3095.  
  3096.         if(Timeout < 1)
  3097.             Timeout = 5 * MILLION;
  3098.  
  3099.         TimeRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  3100.         TimeRequest -> tr_time . tv_secs    = Timeout >= MILLION ? Timeout / MILLION : 0;
  3101.         TimeRequest -> tr_time . tv_micro    = Timeout % MILLION;
  3102.  
  3103.         SetSignal(0,SIG_TIMER);
  3104.  
  3105.         SendIO(TimeRequest);
  3106.  
  3107.         FOREVER
  3108.         {
  3109.             SignalSet = Wait(SIG_TIMER | SIG_SERIAL | SIGBREAKF_CTRL_D);
  3110.  
  3111.                 /* We are to abort the job. */
  3112.  
  3113.             if(SignalSet & SIGBREAKF_CTRL_D)
  3114.             {
  3115.                 Matching = NULL;
  3116.                 break;
  3117.             }
  3118.  
  3119.                 /* Serial data came in... */
  3120.  
  3121.             if(SignalSet & SIG_SERIAL)
  3122.             {
  3123.                 if(Status == STATUS_HOLDING)
  3124.                     Status = STATUS_READY;
  3125.  
  3126.                 /* Any news? */
  3127.  
  3128.                 if(CheckIO(ReadRequest))
  3129.                 {
  3130.                     LONG Length;
  3131.  
  3132.                     if(!WaitIO(ReadRequest))
  3133.                     {
  3134.                         /* Send the byte to the console. */
  3135.  
  3136.                         ConProcess(ReadBuffer,1);
  3137.  
  3138.                         if(Matching == NULL)
  3139.                             Matching = SequenceFilter(((UBYTE *)ReadBuffer)[0]);
  3140.  
  3141.                         /* Loop until all data has been processed. */
  3142.  
  3143. Loop:                        do
  3144.                         {
  3145.                             /* Check how many bytes are still in
  3146.                              * the serial buffer.
  3147.                              */
  3148.  
  3149.                             WriteRequest -> IOSer . io_Command = SDCMD_QUERY;
  3150.  
  3151.                             DoIO(WriteRequest);
  3152.  
  3153.                             if(Length = WriteRequest -> IOSer . io_Actual)
  3154.                             {
  3155.                                 if(Length > Config . SerBuffSize)
  3156.                                     Length = Config . SerBuffSize;
  3157.  
  3158.                                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  3159.                                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  3160.                                 ReadRequest -> IOSer . io_Length    = Length;
  3161.  
  3162.                                 if(!DoIO(ReadRequest))
  3163.                                 {
  3164.                                     /* Send the data to the console. */
  3165.  
  3166.                                     ConProcess(ReadBuffer,Length);
  3167.                                 }
  3168.  
  3169.                                 if(!Matching)
  3170.                                 {
  3171.                                     for(i = 0 ; i < Length ; i++)
  3172.                                     {
  3173.                                         if(Matching = SequenceFilter(((UBYTE *)ReadBuffer)[i]))
  3174.                                             break;
  3175.                                     }
  3176.                                 }
  3177.                             }
  3178.                         }
  3179.                         while(Length);
  3180.                     }
  3181.  
  3182.                         /* Ask for another byte. */
  3183.  
  3184.                     ReadRequest -> IOSer . io_Command    = CMD_READ;
  3185.                     ReadRequest -> IOSer . io_Data        = ReadBuffer;
  3186.                     ReadRequest -> IOSer . io_Length     = 1;
  3187.  
  3188.                     SetSignal(0,SIG_SERIAL);
  3189.  
  3190.                     SendIO(ReadRequest);
  3191.                 }
  3192.             }
  3193.  
  3194.                 /* Timeout has occured. */
  3195.  
  3196.             if(SignalSet & SIG_TIMER)
  3197.                 break;
  3198.  
  3199.                 /* We've made a match! */
  3200.  
  3201.             if(Matching)
  3202.                 break;
  3203.         }
  3204.  
  3205.             /* Is the timer still active? If so, cancel it. */
  3206.  
  3207.         if(!CheckIO(TimeRequest))
  3208.             AbortIO(TimeRequest);
  3209.  
  3210.             /* Wait for timer to return. */
  3211.  
  3212.         WaitIO(TimeRequest);
  3213.  
  3214.             /* Determine the result code if a match has been
  3215.              * made.
  3216.              */
  3217.  
  3218.         if(Matching)
  3219.             strcpy(RexxTextBuffer,Matching -> Sequence);
  3220.         else
  3221.         {
  3222.             RexxTextBuffer[0] = 0;
  3223.  
  3224.             RexxRes1 = RC_WARN;
  3225.         }
  3226.     }
  3227.  
  3228.         /* Clear the list of sequences to check. */
  3229.  
  3230.     ClearSequenceObjects();
  3231.  
  3232.     return(RexxTextBuffer);
  3233. }
  3234.  
  3235. UBYTE *
  3236. RexxToneDial(UBYTE *String)
  3237. {
  3238.     if(ToneDial(String))
  3239.         DeleteTone();
  3240.     else
  3241.         RexxRes1 = RC_ERROR;
  3242.  
  3243.     return(NULL);
  3244. }
  3245.  
  3246. UBYTE *
  3247. RexxSimpleRequest(UBYTE *String)
  3248. {
  3249.     BlockWindows();
  3250.  
  3251.     MyEasyRequest(Window,String,"Continue");
  3252.  
  3253.     ReleaseWindows();
  3254.  
  3255.     return(NULL);
  3256. }
  3257.  
  3258. UBYTE *
  3259. RexxTwoGadRequest(UBYTE *String)
  3260. {
  3261.     BYTE Result;
  3262.  
  3263.     BlockWindows();
  3264.  
  3265.     Result = MyEasyRequest(Window,String,"Yes|No");
  3266.  
  3267.     ReleaseWindows();
  3268.  
  3269.     if(Result)
  3270.         return("YES");
  3271.     else
  3272.         return("NO");
  3273. }
  3274.  
  3275. UBYTE *
  3276. RexxFileRequest(UBYTE *String)
  3277. {
  3278.     struct AslFileRequest *FileRequest;
  3279.  
  3280.     BlockWindows();
  3281.  
  3282.     MoveScreen(Screen,0,-Screen -> TopEdge);
  3283.  
  3284.     ScreenToFront(Screen);
  3285.  
  3286.     if(FileRequest = GetFile(String,"","",RexxTextBuffer,NULL,FALSE,FALSE,FALSE,NULL))
  3287.     {
  3288.         if(RexxTextBuffer[0])
  3289.         {
  3290.             FreeAslRequest(FileRequest);
  3291.  
  3292.             ReleaseWindows();
  3293.  
  3294.             return(RexxTextBuffer);
  3295.         }
  3296.         else
  3297.         {
  3298.             FreeAslRequest(FileRequest);
  3299.  
  3300.             ReleaseWindows();
  3301.  
  3302.             return(NULL);
  3303.         }
  3304.     }
  3305.     else
  3306.     {
  3307.         ReleaseWindows();
  3308.  
  3309.         return(NULL);
  3310.     }
  3311. }
  3312.  
  3313. UBYTE *
  3314. RexxSpeak(UBYTE *String)
  3315. {
  3316.     Say(String);
  3317.  
  3318.     return(NULL);
  3319. }
  3320.  
  3321. VOID
  3322. Rexx2Front()
  3323. {
  3324.     if(RexxWindow)
  3325.         BumpWindow(RexxWindow);
  3326. }
  3327.  
  3328. VOID
  3329. Term2Front()
  3330. {
  3331.     BumpWindow(Window);
  3332. }
  3333.  
  3334. VOID
  3335. Display2Front()
  3336. {
  3337.     if(BufferProcess)
  3338.         Signal(BufferProcess,SIGBREAKF_CTRL_D);
  3339. }
  3340.  
  3341. VOID
  3342. CloseDisplay()
  3343. {
  3344.     if(BufferProcess)
  3345.         Signal(BufferProcess,SIGBREAKF_CTRL_C);
  3346. }
  3347.  
  3348. VOID
  3349. QuietExit()
  3350. {
  3351.     ExitQuietly = TRUE;
  3352. }
  3353.  
  3354.     /* RexxASyncCommand(struct RexxMsg *RexxMsg):
  3355.      *
  3356.      *    This routine handles the asynchronous Rexx
  3357.      *    commands and complains if the command passed
  3358.      *    to it cannot be executed asynchronously.
  3359.      */
  3360.  
  3361. BYTE
  3362. RexxASyncCommand(struct RexxMsg *RexxMsg,UBYTE *Arg1,UBYTE *Arg2)
  3363. {
  3364.     LONG    ArgCount = 0;
  3365.     STRPTR    StringResult = NULL;
  3366.     WORD    i;
  3367.     LONG    RexxRes1 = RC_OK;
  3368.  
  3369.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3370.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3371.  
  3372.     if(!Stricmp(Arg1,"QUERY"))
  3373.     {
  3374.         if(!Stricmp(Arg2,"COLOUR"))
  3375.         {
  3376.             LONG Colour;
  3377.  
  3378.             GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3379.  
  3380.             Colour = atol(Arg1);
  3381.  
  3382.             if(Colour >= 0 && Colour < (1 << (Config . ColourMode == COLOUR_EIGHT ? 3 : Screen -> RastPort . BitMap -> Depth)))
  3383.             {
  3384.                 SPrintf(RexxTextBuffer,"%03lx",Config . Colours[Colour]);
  3385.  
  3386.                 StringResult = RexxTextBuffer;
  3387.             }
  3388.             else
  3389.                 RexxRes1 = RC_ERROR;
  3390.         }
  3391.         else
  3392.         {
  3393.             if(!Stricmp(Arg2,"MACRO"))
  3394.             {
  3395.                 LONG Value,Qualifier = -1;
  3396.  
  3397.                 GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3398.  
  3399.                 for(i = 0 ; i < 4 ; i++)
  3400.                 {
  3401.                     if(!Stricmp(Qualifiers[i],Arg2))
  3402.                     {
  3403.                         Qualifier = i;
  3404.                         break;
  3405.                     }
  3406.                 }
  3407.  
  3408.                 if(Qualifier != -1)
  3409.                 {
  3410.                     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3411.  
  3412.                     Value = atol(Arg2);
  3413.  
  3414.                     if(Value >= 0 && Value <= 9)
  3415.                         StringResult = MacroKeys -> Keys[Qualifier][Value];
  3416.                     else
  3417.                         RexxRes1 = RC_ERROR;
  3418.                 }
  3419.                 else
  3420.                     RexxRes1 = RC_ERROR;
  3421.             }
  3422.             else
  3423.             {
  3424.                 for(i = 0 ; i < NUMQUERIES ; i++)
  3425.                 {
  3426.                     if(!Stricmp(Arg2,QueryCommands[i] . String))
  3427.                         StringResult = (*QueryCommands[i] . Routine)();
  3428.                 }
  3429.             }
  3430.         }
  3431.     }
  3432.     else
  3433.     {
  3434.         for(i = 0 ; i < NUMASYNCS ; i++)
  3435.         {
  3436.             if(!Stricmp(Arg1,ASyncCommands[i] . String))
  3437.             {
  3438.                 (*ASyncCommands[i] . Routine)();
  3439.  
  3440.                 i = -1;
  3441.  
  3442.                 break;
  3443.             }
  3444.         }
  3445.  
  3446.         if(i != -1)
  3447.             return(FALSE);
  3448.     }
  3449.  
  3450.     ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3451.  
  3452.     return(TRUE);
  3453. }
  3454.  
  3455.     /* RexxSyncCommand(struct RexxMsg *RexxMsg):
  3456.      *
  3457.      *    Handles the synchronous Rexx commands and returns the
  3458.      *    message if no matching command is found.
  3459.      */
  3460.  
  3461. VOID
  3462. RexxSyncCommand(struct RexxMsg *RexxMsg,UBYTE *Arg1,UBYTE *Arg2)
  3463. {
  3464.     LONG    ArgCount = 0,Count2;
  3465.     STRPTR    StringResult = NULL;
  3466.     WORD    i;
  3467.  
  3468.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3469.  
  3470.         /* Save position of second argument for the
  3471.          * Rexx commands.
  3472.          */
  3473.  
  3474.     Count2 = ArgCount;
  3475.  
  3476.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3477.  
  3478.     RexxRes1 = RC_OK;
  3479.  
  3480.         /* Look if it's a `set' command. */
  3481.  
  3482.     if(!Stricmp(Arg1,"SET"))
  3483.     {
  3484.         for(i = 0 ; i < SETMOREPARAMS ; i++)
  3485.         {
  3486.             if(!Stricmp(Arg2,SetCommands[i] . String))
  3487.             {
  3488.                 (*SetCommands[i] . Routine)(&RexxMsg -> rm_Args[0][ArgCount],NULL);
  3489.  
  3490.                 ReplyRexxCommand(RexxMsg,RexxRes1,0,NULL);
  3491.  
  3492.                 return;
  3493.             }
  3494.         }
  3495.  
  3496.         for(i = SETMOREPARAMS ; i < NUMSETS ; i++)
  3497.         {
  3498.             if(!Stricmp(Arg2,SetCommands[i] . String))
  3499.             {
  3500.                 GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3501.  
  3502.                 (*SetCommands[i] . Routine)(Arg2,NULL);
  3503.  
  3504.                 ReplyRexxCommand(RexxMsg,RexxRes1,0,NULL);
  3505.  
  3506.                 return;
  3507.             }
  3508.         }
  3509.     }
  3510.  
  3511.     for(i = 0 ; i < REXXMOREPARAMS ; i++)
  3512.     {
  3513.         if(!Stricmp(Arg1,RexxCommands[i] . String))
  3514.         {
  3515.             StringResult = (*RexxCommands[i] . Routine)(&RexxMsg -> rm_Args[0][Count2],NULL);
  3516.  
  3517.             ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3518.  
  3519.             return;
  3520.         }
  3521.     }
  3522.  
  3523.     for(i = REXXMOREPARAMS ; i < NUMREXX ; i++)
  3524.     {
  3525.         if(!Stricmp(Arg1,RexxCommands[i] . String))
  3526.         {
  3527.             StringResult = (*RexxCommands[i] . Routine)(Arg2,&RexxMsg -> rm_Args[0][Count2 + 1]);
  3528.  
  3529.             ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3530.  
  3531.             return;
  3532.         }
  3533.     }
  3534.  
  3535.     ReplyRexxCommand(RexxMsg,RC_ERROR,0,NULL);
  3536. }
  3537.  
  3538.     /* RexxServer(VOID):
  3539.      *
  3540.      *    Asynchronous ARexx host server.
  3541.      */
  3542.  
  3543. VOID __saveds
  3544. RexxServer(VOID)
  3545. {
  3546.     UBYTE         Arg1[80],Arg2[80];
  3547.  
  3548.     struct MsgPort    *RexxPort;
  3549.     struct RexxMsg    *RexxMsg;
  3550.  
  3551.     ULONG         SignalSet;
  3552.  
  3553.     BYTE         Terminated = FALSE;
  3554.  
  3555.         /* Create the public host port. */
  3556.  
  3557.     if(RexxPort = (struct MsgPort *)CreateMsgPort())
  3558.     {
  3559.         RexxPort -> mp_Node . ln_Name    = TermIDString;
  3560.         RexxPort -> mp_Node . ln_Pri    = 1;
  3561.  
  3562.             /* Make it a public port. */
  3563.  
  3564.         AddPort(RexxPort);
  3565.  
  3566.             /* Signal our father that we're running. */
  3567.  
  3568.         Signal(ThisProcess,SIGBREAKF_CTRL_C);
  3569.  
  3570.             /* Go into loop and wait for input. */
  3571.  
  3572.         while(!Terminated)
  3573.         {
  3574.             SignalSet = Wait(SIGBREAKF_CTRL_C | (1 << RexxPort -> mp_SigBit));
  3575.  
  3576.                 /* This is probably a Rexx command. */
  3577.  
  3578.             if(SignalSet & (1 << RexxPort -> mp_SigBit))
  3579.             {
  3580.                     /* Pick up all the messages. */
  3581.  
  3582.                 while(RexxMsg = (struct RexxMsg *)GetMsg(RexxPort))
  3583.                 {
  3584.                     Arg1[0] = Arg2[0] = 0;
  3585.  
  3586.                         /* At first try to run the
  3587.                          * command asynchronously.
  3588.                          * If this turns out to be
  3589.                          * somewhat `impossible' pass
  3590.                          * it to the `term' main process
  3591.                          * or - if in batch mode - try
  3592.                          * to deal with the message
  3593.                          * on our own.
  3594.                          */
  3595.  
  3596.                     if(!RexxASyncCommand(RexxMsg,Arg1,Arg2))
  3597.                     {
  3598.                         if(!BatchMode)
  3599.                             PutMsg(TermRexxPort,RexxMsg);
  3600.                         else
  3601.                             ReplyRexxCommand(RexxMsg,-1,0,NULL);
  3602.                     }
  3603.                 }
  3604.             }
  3605.  
  3606.             if(SignalSet & SIGBREAKF_CTRL_C)
  3607.                 Terminated = TRUE;
  3608.         }
  3609.  
  3610.         Forbid();
  3611.  
  3612.         while(RexxMsg = (struct RexxMsg *)GetMsg(RexxPort))
  3613.             ReplyRexxCommand(RexxMsg,-1,0,NULL);
  3614.  
  3615.         RemPort(RexxPort);
  3616.  
  3617.         DeleteMsgPort(RexxPort);
  3618.     }
  3619.  
  3620.     Forbid();
  3621.  
  3622.     RexxProcess = NULL;
  3623.  
  3624.     Signal(ThisProcess,SIGBREAKF_CTRL_C);
  3625. }
  3626.  
  3627.     /* HandleRexx():
  3628.      *
  3629.      *    Tiny & simple subroutine to read and examine all
  3630.      *    messages coming in to be processed synchronously
  3631.      *    by the `term' main process.
  3632.      */
  3633.  
  3634. VOID
  3635. HandleRexx()
  3636. {
  3637.     struct RexxMsg    *RexxMsg;
  3638.     UBYTE         Arg1[80],Arg2[256];
  3639.  
  3640.     while(RexxMsg = (struct RexxMsg *)GetMsg(TermRexxPort))
  3641.     {
  3642.         Arg1[0] = Arg2[0] = 0;
  3643.  
  3644.         RexxSyncCommand(RexxMsg,Arg1,Arg2);
  3645.     }
  3646. }
  3647.